#include <QMessageBox>
#include "pages.h"
#include <QFile>
#include <string.h>

void setView(QComboBox* target)
{
    QListView* view = new QListView();
    view->verticalScrollBar()->setStyleSheet("QScrollBar{background:transparent; width: 30px;}"
                      "QScrollBar::handle{background-color:darkgray;min-height: 20px;}"
                      "QScrollBar::handle:pressed{background:gray;}"
                      "QScrollBar::sub-line{background:transparent;}"
                      "QScrollBar::add-line{background:transparent;}");
    QSize size = view->sizeHint();
    size.setHeight(32);
    view->setGridSize(size);

    target->setView(view);
}

int TestPage::getStructLen()
{
    return sizeof(ETC_Send);
}

void TestPage::getsendUdp(char * ch,int flag)
{
    etc_send=(ETC_Send*)ch;
    memset(etc_send,0x00,sizeof(ETC_Send));
    memcpy(etc_send->de_name,"sanwei",6);

    //if (rdoGC->isChecked())     //工程算法
        etc_send->sf=1+'0';
   // else                        //理论算法
   //     etc_send->sf=1+'0';
    if (flag==0)                //复位命令
    {
        etc_send->sf='!';
    }
    else if(flag==1)            //延时时间测量命令
    {
        etc_send->sf='#';
    }
    else if (flag==3)           //对时守时测试命令
    {
        etc_send->sf='*';
        etc_send->tbfs=itype+'0';     //b码:0  ;光PPS:1；同步输出：2
    }
    else                            //flag==2时误差测量
    {
        etc_send->tbfs=cboTbfs->currentIndex()+'0';
        etc_send->bzxz=cboBzSelect->currentIndex()+'0';
        if ((cboBzSelect->currentIndex()==4)||(cboBzSelect->currentIndex()==5))
            etc_send->xdyz=txtBzXdy->text().toFloat();
        else
             etc_send->xdyz=0+'0';
        etc_send->bcxz=cboBcSelect->currentIndex()+'0';
        if (cboBcSelect->currentIndex()<=3)
            etc_send->ydyz=0;
        else if (cboBcSelect->currentIndex()==4)
            etc_send->ydyz=txtBcXdy->text().toFloat();
        else if ((cboBcSelect->currentIndex()==5)||(cboBcSelect->currentIndex()==6))
            etc_send->ydyz=cboBctd->currentText().toFloat();
        etc_send->ft3_tdh=cboBctd->currentText().toInt();
        //  etc_send->xbNum=cboXbcs->currentText().toInt();
        //    etc_send->xbValue=txtXbYxz->text().toFloat();

        etc_send->xbNum = harmonicChoose;

        etc_send->xbValue=1.0;

        qDebug()<<etc_send->ydyz;
    }
    if(cboCTPT->currentIndex() == 0) // send the rating of the transformer to hardware
    {
        etc_send->xbValue = txtEdyc->text().toFloat();
    //    etc_send->xbNum = '0'; // 0 for CT, 1 for PT
    }
    else if(cboEdycDw->currentIndex() == 0)
    {
        etc_send->xbValue = txtEdyc->text().toFloat() * 100; // decided by hardware-Zhang
    //    etc_send->xbNum = '1';
    }
    else
    {
        etc_send->xbValue = txtEdyc->text().toFloat() * 57.735;
    //    etc_send->xbNum = '1';
    }
   // char netport[4];    /*输入端口*/
  //  cboInput->currentIndex()
    for(int i=0;i<4;i++)
        etc_send->netport[i]=iNetPort + '0';       //初始化
    etc_send->netport[0]=cboInput->currentIndex()+'0';
    for(int i=0;i<20;i++)
        etc_send->ex[i]=0;
    if (flag==3)           //对时守时测试命令 时间设置
    {
        etc_send->ex[0]=itime >> 24 & 0xFF;
        etc_send->ex[1]=itime >> 16 & 0xFF;
        etc_send->ex[2]=itime >> 8 & 0xFF;
        etc_send->ex[3]=itime  & 0xFF;
    }
}

TestPage::TestPage(QWidget *parent)
    : QWidget(parent)
{
    QFont ft;
    ft.setPointSize(8);
    ft.setBold(true);

    setStyleSheet("font-size:20px;");

    iNetPort=0;

    widget=new QWidget();
    widget->setStyleSheet("background-color:#000000");

#ifndef i386
    widget->setFixedSize(980,350);
#else
    widget->setFixedSize(980,300);
#endif
    //widget->setMaximumHeight(250);
    //widget->setMinimumWidth(820);

    labDw=new QLabel(tr("单位"));
    labDw->setWordWrap(true);
    labDw->setAlignment(Qt::AlignTop);
    labDw->setFixedWidth(100);
    QString s = "标准 最大值";
    labDw->setText(s.split(" ", QString::SkipEmptyParts).join("\n"));

    maxBfb = new QLabel("0.00");
    maxBfb->setStyleSheet("color:yellow;");

    labFz5p=new QLabel("5-");
    labFz4p=new QLabel("4-");
    labFz3p=new QLabel("3-");
    labFz2p=new QLabel("2-");
    labFz1p=new QLabel("1-");
    labFz0=new QLabel("0");
    labFz5n=new QLabel("-5-");
    labFz4n=new QLabel("-4-");
    labFz3n=new QLabel("-3-");
    labFz2n=new QLabel("-2-");
    labFz1n=new QLabel("-1-");

    labFz5p->setFixedHeight(13);
    labFz4p->setFixedHeight(13);
    labFz3p->setFixedHeight(13);
    labFz2p->setFixedHeight(13);
    labFz1p->setFixedHeight(13);
    labFz0->setFixedHeight(13);
    labFz5n->setFixedHeight(13);
    labFz4n->setFixedHeight(13);
    labFz3n->setFixedHeight(13);
    labFz2n->setFixedHeight(13);
    labFz1n->setFixedHeight(13);

    labFz5p->setAlignment(Qt::AlignRight);
    labFz4p->setAlignment(Qt::AlignRight);
    labFz3p->setAlignment(Qt::AlignRight);
    labFz2p->setAlignment(Qt::AlignRight);
    labFz1p->setAlignment(Qt::AlignRight);
    labFz0->setAlignment(Qt::AlignRight);
    labFz5n->setAlignment(Qt::AlignRight);
    labFz4n->setAlignment(Qt::AlignRight);
    labFz3n->setAlignment(Qt::AlignRight);
    labFz2n->setAlignment(Qt::AlignRight);
    labFz1n->setAlignment(Qt::AlignRight);

    labFz5p->setFont(ft);
    labFz4p->setFont(ft);
    labFz3p->setFont(ft);
    labFz2p->setFont(ft);
    labFz1p->setFont(ft);
    labFz0->setFont(ft);
    labFz5n->setFont(ft);
    labFz4n->setFont(ft);
    labFz3n->setFont(ft);
    labFz2n->setFont(ft);
    labFz1n->setFont(ft);

    labFz5p->setStyleSheet("color:rgb(250,255,150);");
    labFz4p->setStyleSheet("color:rgb(250,255,150);");
    labFz3p->setStyleSheet("color:rgb(250,255,150);");
    labFz2p->setStyleSheet("color:rgb(250,255,150);");
    labFz1p->setStyleSheet("color:rgb(250,255,150);");
    labFz0->setStyleSheet("color:rgb(250,255,150);");
    labFz5n->setStyleSheet("color:rgb(250,255,150);");
    labFz4n->setStyleSheet("color:rgb(250,255,150);");
    labFz3n->setStyleSheet("color:rgb(250,255,150);");
    labFz2n->setStyleSheet("color:rgb(250,255,150);");
    labFz1n->setStyleSheet("color:rgb(250,255,150);");

    labFz0->setMinimumWidth(60);

    ft.setPointSize(9);
    labFuzhi=new QLabel(tr("幅值"));
    labFuzhiValue=new QLabel(tr("0"));
    labFuzhi->setMinimumWidth(20);
    labFuzhiValue->setMinimumWidth(100);
 //   labFuzhi->setStyleSheet("color:rgb(250,155,50);");
//    labFuzhiValue->setStyleSheet("color:rgb(250,155,50);");
    labFuzhi->setFont(ft);
    labFuzhiValue->setFont(ft);

    labSync=new QLabel("");
    labSync->setMinimumWidth(40);
    labSync->setMaximumWidth(20);
 //   labSync->setStyleSheet("color:rgb(250,255,0);");
    labSync->setFont(ft);
    labSyncPng=new QLabel("");
    labSyncPng->setMinimumWidth(7);
    labSyncPng->setMaximumWidth(5);

    rdoCltd=new QRadioButton(tr("仅显示测量通道"));
    rdoAlltd=new QRadioButton(tr("显示全部通道"));
    rdoCltd->setFont(ft);
    rdoAlltd->setFont(ft);
  //  rdoCltd->setStyleSheet("color:rgb(250,155,100);");
  //  rdoAlltd->setStyleSheet("color:rgb(250,155,100);");
    rdoAlltd->setChecked(true);
    inittabTd();

    QHBoxLayout *s1Layout = new QHBoxLayout;
    s1Layout->addWidget(tabTd);
    s1Layout->addStretch(1);
    s1Layout->addWidget(rdoAlltd);
    s1Layout->addWidget(rdoCltd);

    QVBoxLayout *fz1Layout = new QVBoxLayout;
    fz1Layout->addSpacing(5);
    fz1Layout->addWidget(labFz5p);
    fz1Layout->addWidget(labFz4p);
    fz1Layout->addWidget(labFz3p);
    fz1Layout->addWidget(labFz2p);
    fz1Layout->addWidget(labFz1p);
    fz1Layout->addWidget(labFz0);
    fz1Layout->addWidget(labFz1n);
    fz1Layout->addWidget(labFz2n);
    fz1Layout->addWidget(labFz3n);
    fz1Layout->addWidget(labFz4n);
    fz1Layout->addWidget(labFz5n);

    fz1Layout->setSpacing(0);
    QVBoxLayout *fz2Layout = new QVBoxLayout;
    fz2Layout->addStretch(1);
    fz2Layout->addWidget(labDw);
    fz2Layout->addWidget(maxBfb);
    fz2Layout->addStretch(1);
    QHBoxLayout *fzLayout = new QHBoxLayout;
    fzLayout->addLayout(fz2Layout);
    fzLayout->addStretch(1);
    fzLayout->addLayout(fz1Layout);

    labFz5p->setVisible(false);
    labFz4p->setVisible(false);
    labFz3p->setVisible(false);
    labFz2p->setVisible(false);
    labFz1p->setVisible(false);
    labFz0->setVisible(false);
    labFz5n->setVisible(false);
    labFz4n->setVisible(false);
    labFz3n->setVisible(false);
    labFz2n->setVisible(false);
    labFz1n->setVisible(false);

//    labFz3->setVisible(true);
//    labFz2->setVisible(true);
//    labFz1->setVisible(true);
//    labFz3a->setVisible(true);
//    labFz2a->setVisible(true);
//    labFz1a->setVisible(true);

 //   fzLayout->addSpacing(50);
 //   fzLayout->addWidget(labFuzhi);
 //   fzLayout->addWidget(labFuzhiValue);
    fzLayout->addStretch(1);
    QHBoxLayout *widgetLayout = new QHBoxLayout;
    widgetLayout->addLayout(fzLayout);
    widgetLayout->addWidget(widget);
 //   widgetLayout->addStretch(1);
    widgetLayout->addSpacing(50);
  //  widgetLayout->addStretch(1);

    QLabel *labBzys=new QLabel(tr("标准:白色"));
    labBcys=new QLabel(tr("被测:绿色"));
    labBzys->setFont(ft);
    labBcys->setFont(ft);

    ft.setPointSize(10);
    btnTest=new QPushButton(tr("开始"));
    btnTest->setMinimumWidth(100);
    btnTest->setMinimumHeight(60);
    QLabel *labSpace=new QLabel("");
    labSpace->setMinimumWidth(100);

    btnTest->setFont(ft);
    btnAll=new QPushButton(tr("全帧解析"));
    btnAll->setMinimumWidth(100);
    btnAll->setMinimumHeight(60);
    btnAll->setFont(ft);

    QVBoxLayout *controlLayout = new QVBoxLayout;
    controlLayout->addWidget(labBzys);
    controlLayout->addWidget(labBcys);
    controlLayout->addWidget(btnAll);
    controlLayout->addStretch(1);
    controlLayout->addWidget(labSpace);
    controlLayout->addWidget(btnTest);

    ft.setPointSize(9);

    widgetLayout->addLayout(controlLayout);
    widgetLayout->setSpacing(0);
    widgetLayout->addSpacing(50);

    QHBoxLayout *syncLayout = new QHBoxLayout;
    syncLayout->addWidget(labSyncPng);
    syncLayout->addWidget(labSync);
    syncLayout->addStretch(1);

    ft.setPointSize(12);
    labInfo=new QLabel();
    labInfo->setStyleSheet("color:rgb(250,250,100);");//12,190,65
    labInfo->setFont(ft);

    ft.setPointSize(9);
    QLabel *labBzHgq=new QLabel(tr("标准互感器"));
    labBzHgq->setAlignment(Qt::AlignCenter);
//    labBzHgq->setStyleSheet("color:rgb(12,190,65);");
    labBzHgq->setFont(ft);
    QLabel *labBcHgq=new QLabel(tr("被测互感器"));
    labBcHgq->setAlignment(Qt::AlignCenter);
 //   labBcHgq->setStyleSheet("color:rgb(12,190,65);");
    labBcHgq->setFont(ft);
    QLabel *labBfd=new QLabel(tr("百分点(%)"));
    labBfd->setAlignment(Qt::AlignCenter);
  //  labBfd->setStyleSheet("color:rgb(12,190,65);");
    labBfd->setMinimumWidth(100);
    labBfd->setFont(ft);

    ft.setPointSize(10);
    labyxz=new QLabel(tr("有效值(%)"));
 //   labyxz->setStyleSheet("color:rgb(12,190,65);");
    labyxz->setFont(ft);
    labyxz->setMinimumWidth(130);
    QLabel *labxw=new QLabel(tr("相位值(')"));
 //   labxw->setStyleSheet("color:rgb(12,190,65);");
    labxw->setMinimumWidth(130);
    labxw->setFont(ft);

    txtBFB=new QLineEdit();
    txtBFB->setMaximumWidth(150);
    txtBFB->setMinimumHeight(65);

    ft.setPointSize(14);
    txtBFB->setFont(ft);
    ft.setPointSize(10);
//    txtBFB->setStyleSheet("QLineEdit{border-width:0;border-style:solid;background:rgb(14,55,76);color:rgb(255,255,255)}");

    txtBzYxz=new QLineEdit();
    txtBzYxz->setMinimumWidth(130);
   // txtBzYxz->setStyleSheet("QLineEdit{border-width:0;border-style:solid;background:rgb(14,55,76);color:rgb(255,255,255)}");

    txtBzYxz->setFont(ft);
    txtBcYxz=new QLineEdit();
    txtBcYxz->setMinimumWidth(130);
//    txtBcYxz->setStyleSheet("QLineEdit{border-width:0;border-style:solid;background:rgb(14,55,76);color:rgb(255,255,255)}");
    txtBcYxz->setFont(ft);
    txtBzXw=new QLineEdit();
    txtBzXw->setMinimumWidth(130);
 //   txtBzXw->setStyleSheet("QLineEdit{border-width:0;border-style:solid;background:rgb(14,55,76);color:rgb(255,255,255)}");
    txtBzXw->setFont(ft);
    txtBcXw=new QLineEdit();
    txtBcXw->setMinimumWidth(130);
  //  txtBcXw->setStyleSheet("QLineEdit{border-width:0;border-style:solid;background:rgb(14,55,76);color:rgb(255,255,255)}");
    txtBcXw->setFont(ft);

    ft.setPointSize(10);
    QLabel *labBc=new QLabel(tr("比值差(%)"));
    labBc->setFont(ft);
 //   labBc->setStyleSheet("color:rgb(168,190,18);");//12,190,65
    QLabel *labJc=new QLabel(tr("相位差(')"));
    labJc->setFont(ft);
 //   labJc->setStyleSheet("color:rgb(168,190,18);");
    txtBc=new QLineEdit();
    txtJc=new QLineEdit();
    txtBc->setFont(ft);
 //   txtBc->setStyleSheet("QLineEdit{border-width:0;border-style:solid;background:rgb(14,25,26);color:rgb(255,255,255)}");
    txtBc->setMaximumWidth(160);
    txtJc->setFont(ft);
 //   txtJc->setStyleSheet("QLineEdit{border-width:0;border-style:solid;background:rgb(14,25,26);color:rgb(255,255,255)}");
    txtJc->setMaximumWidth(150);

    btnSave=new QPushButton(tr("存储"));
    btnSave->setFont(ft);
    btnSave->setMaximumWidth(100);
    btnSave->setMinimumHeight(60);

    ft.setPointSize(10);
    QLabel *labMax=new QLabel(tr("最大值"));
    labMax->setAlignment(Qt::AlignCenter);
    labMax->setFont(ft);
 //   labMax->setStyleSheet("color:rgb(12,190,65);");
    QLabel *labMin=new QLabel(tr("最小值"));
    labMin->setAlignment(Qt::AlignCenter);
    labMin->setFont(ft);
 //   labMin->setStyleSheet("color:rgb(12,190,65);");
    QLabel *labAvg=new QLabel(tr("平均值"));
    labAvg->setAlignment(Qt::AlignCenter);
    labAvg->setFont(ft);
 //   labAvg->setStyleSheet("color:rgb(12,190,65);");
    QLabel *labBzc=new QLabel(tr("比值差(%)"));
    labBzc->setFont(ft);
 //   labBzc->setStyleSheet("color:rgb(12,190,65);");
    QLabel *labXwc=new QLabel(tr("相位差(')"));
    labXwc->setFont(ft);
 //   labXwc->setStyleSheet("color:rgb(12,190,65);");

    txtMinBc=new QLineEdit();
    txtMinBc->setMinimumWidth(130);
 //   txtMinBc->setStyleSheet("QLineEdit{border-width:0;border-style:solid;background:rgb(14,55,76);color:rgb(255,255,255)}");
    txtMinJc=new QLineEdit();
    txtMinJc->setMinimumWidth(130);
 //   txtMinJc->setStyleSheet("QLineEdit{border-width:0;border-style:solid;background:rgb(14,55,76);color:rgb(255,255,255)}");
    txtMaxBc=new QLineEdit();
    txtMaxBc->setMinimumWidth(130);
  //  txtMaxBc->setStyleSheet("QLineEdit{border-width:0;border-style:solid;background:rgb(14,55,76);color:rgb(255,255,255)}");
    txtMaxJc=new QLineEdit();
    txtMaxJc->setMinimumWidth(130);;
 //   txtMaxJc->setStyleSheet("QLineEdit{border-width:0;border-style:solid;background:rgb(14,55,76);color:rgb(255,255,255)}");
    txtAvgBc=new QLineEdit();
    txtAvgBc->setMinimumWidth(130);
 //   txtAvgBc->setStyleSheet("QLineEdit{border-width:0;border-style:solid;background:rgb(14,55,76);color:rgb(255,255,255)}");
    txtAvgJc=new QLineEdit();
    txtAvgJc->setMinimumWidth(130);
 //   txtAvgJc->setStyleSheet("QLineEdit{border-width:0;border-style:solid;background:rgb(14,55,76);color:rgb(255,255,255)}");

    QGridLayout *gLayout=new QGridLayout;

    gLayout->addLayout(syncLayout,0,0,1,1);
    gLayout->addWidget(labBzHgq,0,1,1,1);
    gLayout->addWidget(labBcHgq,0,2,1,1);
    gLayout->addWidget(labyxz,1,0,1,1);
    gLayout->addWidget(txtBzYxz,1,1,1,1);
    gLayout->addWidget(txtBcYxz,1,2,1,1);
    gLayout->addWidget(labxw,2,0,1,1);
    gLayout->addWidget(txtBzXw,2,1,1,1);
    gLayout->addWidget(txtBcXw,2,2,1,1);
    gLayout->addWidget(labBfd,0,3,1,1);
    gLayout->addWidget(txtBFB,1,3,2,1);
    gLayout->addWidget(labBc,3,0,1,1);
    gLayout->addWidget(txtBc,3,1,1,1);
    gLayout->addWidget(labJc,3,2,1,1);
    gLayout->addWidget(txtJc,3,3,1,1);
    gLayout->addWidget(btnSave,4,0,1,1);
    gLayout->addWidget(labMax,5,1,1,1);
    gLayout->addWidget(labMin,5,2,1,1);
    gLayout->addWidget(labAvg,5,3,1,1);
    gLayout->addWidget(labBzc,6,0,1,1);
    gLayout->addWidget(txtMaxBc,6,1,1,1);
    gLayout->addWidget(txtMinBc,6,2,1,1);
    gLayout->addWidget(txtAvgBc,6,3,1,1);
    gLayout->addWidget(labXwc,7,0,1,1);
    gLayout->addWidget(txtMaxJc,7,1,1,1);
    gLayout->addWidget(txtMinJc,7,2,1,1);
    gLayout->addWidget(txtAvgJc,7,3,1,1);

    gLayout->setSpacing(0);

    ft.setPointSize(10);
    tabwc=new QTabWidget();
    widgetWc=new QWidget();
    widgetWcData=new QWidget();
    cboTbfs=new QComboBox();
    setView(cboTbfs);
    cboBzSelect=new QComboBox();
    setView(cboBzSelect);
    cboBcSelect=new QComboBox();
    setView(cboBcSelect);
    cboBctd=new QComboBox();
    setView(cboBctd);
    cboCTPT=new QComboBox();
    setView(cboCTPT);
    cboJD=new QComboBox();
    setView(cboJD);
    cboBhCl=new QComboBox();
    setView(cboBhCl);
    txtEdyc=new QLineEdit();
    cboEdycDw=new QComboBox();
    setView(cboEdycDw);
    txtBzXdy=new QLineEdit();
    txtBcXdy=new QLineEdit();
    cboCyfs=new QComboBox();
    setView(cboCyfs);
    txtMac=new QLineEdit();
    txtTestNum=new QLineEdit();
    cboInput=new QComboBox();
    setView(cboInput);
    cboSave=new QComboBox();
    setView(cboSave);
    btnGet=new QPushButton(tr("获取"));

    tabwc->setFont(ft);
    cboTbfs->setFont(ft);
    cboBzSelect->setFont(ft);
    cboBcSelect->setFont(ft);
    cboBctd->setFont(ft);
    cboCTPT->setFont(ft);
    cboJD->setFont(ft);
    cboBhCl->setFont(ft);
    txtEdyc->setFont(ft);
    cboEdycDw->setFont(ft);
    txtBzXdy->setFont(ft);
    txtBcXdy->setFont(ft);
    cboCyfs->setFont(ft);
    txtMac->setFont(ft);
    txtTestNum->setFont(ft);
    cboSave->setFont(ft);
    cboInput->setFont(ft);
    //cboInput->setStyle(new QWindowsStyle);

    tabwc->setMinimumWidth(500);
    tabwc->setMinimumHeight(300);
    cboTbfs->setMinimumWidth(175);
    cboBzSelect->setFixedWidth(240);
    //cboBcSelect->setMinimumWidth(200);
    cboBcSelect->setFixedWidth(240);
    cboBctd->setMinimumWidth(70);
    cboCTPT->setMinimumWidth(125);
    cboJD->setMinimumWidth(80);
    cboBhCl->setMinimumWidth(130);
    txtEdyc->setFixedWidth(95);
    cboEdycDw->setMinimumWidth(70);
    txtBzXdy->setMinimumWidth(100);
    txtBcXdy->setMinimumWidth(100);
    cboCyfs->setMinimumWidth(130);
    txtMac->setMinimumWidth(130);
    txtTestNum->setMaximumWidth(60);
    cboSave->setMinimumWidth(130);
    cboInput->setMinimumWidth(100);

    cboTbfs->addItem(tr("同步输出"));
    cboTbfs->addItem(tr("接受电秒脉冲"));
    cboTbfs->addItem(tr("接收光秒脉冲"));
    cboTbfs->addItem(tr("接收B码电信号"));
    cboTbfs->addItem(tr("接收B码光信号"));
    cboTbfs->addItem(tr("1588对时"));
    cboTbfs->setCurrentIndex(3);
    cboBhCl->addItem(tr("测量通道"));
    cboBhCl->addItem(tr("保护通道"));
    cboBzSelect->addItem(tr("5A"));
    cboBzSelect->addItem(tr("1A"));
    cboBzSelect->addItem(tr("100V"));
    cboBzSelect->addItem(tr("100/√3V"));
    cboBzSelect->addItem(tr("模拟小电压"));
  //  cboBzSelect->addItem(tr("谐波小电压"));
    cboBcSelect->addItem(tr("5A"));
    cboBcSelect->addItem(tr("1A"));
    cboBcSelect->addItem(tr("100V"));
    cboBcSelect->addItem(tr("100/√3V"));
    cboBcSelect->addItem(tr("模拟小电压"));
    cboBcSelect->addItem(tr("光纤 61850-9-2(LE)"));
    cboBcSelect->addItem(tr("光纤 FT3"));
    cboSave->addItem(tr("手动存储"));
    cboSave->addItem(tr("自动存储"));
    cboCyfs->addItem(tr("点对点方式"));
    cboCyfs->addItem(tr("组网方式"));
    cboCTPT->addItem(tr("电流互感器"));
    cboCTPT->addItem(tr("电压互感器"));
    cboInput->addItem(tr("光口1"));
    cboInput->addItem(tr("光口2"));
    cboInput->addItem(tr("电口1"));
    cboInput->addItem(tr("电口2"));
    for(int i=1;i<97;i++)
        cboBctd->addItem(QString::number(i));

    //changeSty(0);

//tabwc->setAttribute(Qt::WA_TranslucentBackground,false);
//widgetWc->setAttribute(Qt::WA_TranslucentBackground,false);
    QLabel *labTbfs=new QLabel(tr("同步方式"));
    QLabel *labBzSelect=new QLabel(tr("标准选择"));
    QLabel *labBcSelect=new QLabel(tr("被测选择"));
    labBctd=new QLabel(tr("被测通道"));
    QLabel *labCTPT=new QLabel(tr("互感器类型"));
    QLabel *labJD=new QLabel(tr("准确度等级"));
    labBhCl=new QLabel(tr("通道类型"));
    QLabel *labEdyc=new QLabel(tr("额定一次"));
    labBzXdy=new QLabel(tr("V"));
    labBcXdy=new QLabel(tr("V"));
    labCyfs=new QLabel(tr("采样方式"));
    labMac=new QLabel(tr("MU地址"));
    QLabel *labSave=new QLabel(tr("存储方式"));
    QLabel *labTestNum=new QLabel(tr("测量次数"));

    labInput=new QLabel(tr("输入端口"));

    QLabel *labHarmonicBlank = new QLabel("谐波选择");
    labHarmonicBlank->setFont(ft);

    QComboBox *cboHarmonicChoose = new QComboBox;
    setView(cboHarmonicChoose);
    cboHarmonicChoose->setFont(ft);
    cboHarmonicChoose->setFixedWidth(140);
    for(int i = 0; i < 22; i++)
    {
        cboHarmonicChoose->addItem(QString::number(i+1)+"次");
    }
    cboHarmonicChoose->setItemText(0,"基波测试");
    harmonicChoose = 1;

    connect(cboHarmonicChoose,SIGNAL(currentIndexChanged(int)),this,SLOT(chooseHarmonic(int)));

    txtBzXdy->setMaxLength(7);
    txtBcXdy->setMaxLength(7);
  /*  txtBzXdy->setVisible(false);
    txtBcXdy->setVisible(false);
    labBzXdy->setVisible(false);
    labBcXdy->setVisible(false);
    labBctd->setVisible(false);
    cboBctd->setVisible(false);
    labBhCl->setVisible(false);
    cboBhCl->setVisible(false);
*/
    labTbfs->setFont(ft);
    labBzSelect->setFont(ft);
    labBcSelect->setFont(ft);
    labBctd->setFont(ft);
    labCTPT->setFont(ft);
    labJD->setFont(ft);
    labBhCl->setFont(ft);
    labEdyc->setFont(ft);
    labBzXdy->setFont(ft);
    labBcXdy->setFont(ft);
    labCyfs->setFont(ft);
    labMac->setFont(ft);
    labSave->setFont(ft);
    labTestNum->setFont(ft);
    labInput->setFont(ft);

    QAction *list_action=new QAction(tr("从扫描列表中获取"),this);
    QAction *scl_action=new QAction(tr("从配置文件中获取"),this);
    QMenu *menu=new QMenu();
    menu->addAction(list_action);
    menu->addAction(scl_action);
    btnGet->setMenu(menu);
    connect(list_action,SIGNAL(triggered()),this,SLOT(slotList()));
    connect(scl_action,SIGNAL(triggered()),this,SLOT(slotScl()));


    QHBoxLayout *tbLayout = new QHBoxLayout;
    tbLayout->addWidget(labTbfs);
    tbLayout->addWidget(cboTbfs);
    tbLayout->addWidget(labCTPT);
    tbLayout->addWidget(cboCTPT);
    tbLayout->addStretch(1);
    QHBoxLayout *bzLayout = new QHBoxLayout;
    bzLayout->addWidget(labBzSelect);
    bzLayout->addWidget(cboBzSelect);    
    bzLayout->addWidget(txtBzXdy);
    bzLayout->addWidget(labBzXdy);
    bzLayout->addStretch(1);
    QHBoxLayout *bcLayout = new QHBoxLayout;
    bcLayout->addWidget(labBcSelect);
    bcLayout->addWidget(cboBcSelect);    
    bcLayout->addWidget(txtBcXdy);
    bcLayout->addWidget(labBcXdy);
    bcLayout->addWidget(labBctd);
    bcLayout->addWidget(cboBctd);

    bcLayout->addStretch(1);
    QHBoxLayout *bctdLayout = new QHBoxLayout;
    bctdLayout->addSpacing(90);
    bctdLayout->addWidget(labBhCl);
    bctdLayout->addWidget(cboBhCl);
    bctdLayout->addStretch(1);
    QHBoxLayout *hgqLayout = new QHBoxLayout;
    hgqLayout->addWidget(labEdyc);
    hgqLayout->addWidget(txtEdyc);
    hgqLayout->addWidget(cboEdycDw);
    hgqLayout->addWidget(labJD);
    hgqLayout->addWidget(cboJD);
    hgqLayout->addStretch(1);
    QHBoxLayout *saveLayout = new QHBoxLayout;
    saveLayout->addWidget(labSave);
    saveLayout->addWidget(cboSave);
    saveLayout->addWidget(labTestNum);
    saveLayout->addWidget(txtTestNum);
    saveLayout->addStretch(1);
    QHBoxLayout *iecLayout = new QHBoxLayout;
    iecLayout->addWidget(labCyfs);
    iecLayout->addWidget(cboCyfs);
    iecLayout->addWidget(labInput);
    iecLayout->addWidget(cboInput);
    iecLayout->addStretch(1);
    QHBoxLayout *macLayout = new QHBoxLayout;
    macLayout->addWidget(labMac);
    macLayout->addSpacing(5);
    macLayout->addWidget(txtMac);
    macLayout->addWidget(btnGet);
    macLayout->addStretch(1);
    QHBoxLayout *layoutHarmonic = new QHBoxLayout;
    layoutHarmonic->addWidget(labHarmonicBlank);
    layoutHarmonic->addWidget(cboHarmonicChoose);
    layoutHarmonic->addStretch(2);
    QVBoxLayout *paraLayout = new QVBoxLayout;
    paraLayout->addLayout(tbLayout);
    paraLayout->addLayout(hgqLayout);
    paraLayout->addLayout(bzLayout);
    paraLayout->addLayout(bcLayout);    
    paraLayout->addLayout(bctdLayout);
    paraLayout->addLayout(iecLayout);
    paraLayout->addLayout(macLayout);
    paraLayout->addLayout(layoutHarmonic);
    paraLayout->addLayout(saveLayout);
    paraLayout->addStretch(1);

    wcTxtLayout = new QVBoxLayout;
    wcTxtLayout->addLayout(gLayout);
    wcTxtLayout->addStretch(1);

    widgetWcTxt=new QWidget();
    widgetWcTxt->setLayout(wcTxtLayout);
    widgetWcTxt->setFixedWidth(650);

    QWidget *widgetSettings = new QWidget;
    widgetSettings->setLayout(paraLayout);
    widgetSettings->setFixedWidth(550);

    QHBoxLayout *wcLayout = new QHBoxLayout;
    wcLayout->addWidget(widgetSettings);
   // wcLayout->addLayout(gLayout);
    wcLayout->addWidget(widgetWcTxt);
    wcLayout->addStretch(1);
//    wcLayout->addWidget(blockHarmonicChoose);
    widgetWc->setLayout(wcLayout);

    QLabel *labXuhao=new QLabel(tr("序号"));
    QLabel *labTbfsa=new QLabel(tr("同步方式"));
    QLabel *labBzxz=new QLabel(tr("标准选择"));
    QLabel *labBcxz=new QLabel(tr("被测选择"));
    QLabel *labDate=new QLabel(tr("测试时间"));
    labDate->setFont(ft);
    labDate->setMinimumWidth(76);
   // labDate->setStyleSheet("color:rgb(255,255,255);");
    labYc=new QLabel(tr("额定一次电流"));
    labYcDw=new QLabel(tr("A"));
    labDataCount=new QLabel("");
 //   labXuhao->setStyleSheet("color:rgb(255,255,255);");
    labXuhao->setFont(ft);
    labXuhao->setMinimumWidth(76);
  //  labTbfsa->setStyleSheet("color:rgb(255,255,255);");
    labTbfsa->setFont(ft);
  //  labBzxz->setStyleSheet("color:rgb(255,255,255);");
    labBzxz->setFont(ft);
    labBzxz->setMinimumWidth(76);
 //   labBcxz->setStyleSheet("color:rgb(255,255,255);");
    labBcxz->setFont(ft);
  //  labYc->setStyleSheet("color:rgb(255,255,255);");
    labYc->setFont(ft);
  //  labYcDw->setStyleSheet("color:rgb(255,255,255);");
    labYcDw->setFont(ft);
  //  labDataCount->setStyleSheet("color:rgb(255,255,255);");
    labDataCount->setFont(ft);
    labDataCount->setMinimumWidth(200);

    txtXuhao=new QLineEdit("");
    txtTbfs=new QLineEdit("");
    txtBzxz=new QLineEdit("");
    txtBcxz=new QLineEdit("");
    txtYc=new QLineEdit("");
    txtDate=new QLineEdit("");

    txtXuhao->setFont(ft);
    txtTbfs->setFont(ft);
    txtBzxz->setFont(ft);
    txtBcxz->setFont(ft);
    txtYc->setFont(ft);
    txtYc->setMaximumWidth(120);
    txtDate->setFont(ft);
    txtDate->setMaximumWidth(190);
    txtDate->setMinimumWidth(190);
 //   txtDate->setStyleSheet("color:rgb(250,155,50);");
    inittabWcData();
    btnFirst=new QPushButton("");
    btnFirst->setMinimumHeight(27);
    btnFirst->setMaximumWidth(27);
    btnFirst->setStyleSheet("background-image:url(:image/first.png);color:rgb(250,155,50);");
    btnPrevious=new QPushButton("");
    btnPrevious->setMinimumHeight(27);
    btnPrevious->setMaximumWidth(27);
    btnPrevious->setStyleSheet("background-image:url(:image/previous.png);color:rgb(250,155,50);");
    btnNext=new QPushButton("");
    btnNext->setMinimumHeight(27);
    btnNext->setMaximumWidth(27);
    btnNext->setStyleSheet("background-image:url(:image/next.png);color:rgb(250,155,50);");
    btnLast=new QPushButton("");
    btnLast->setMinimumHeight(27);
    btnLast->setMaximumWidth(27);
    btnLast->setStyleSheet("background-image:url(:image/last.png);color:rgb(250,155,50);");
    btnDel=new QPushButton("");
    btnDel->setMinimumHeight(27);
    btnDel->setMaximumWidth(27);
    btnDel->setStyleSheet("background-image:url(:image/del.png);color:rgb(250,155,50);");
    btnFind=new QPushButton("");
    btnFind->setMinimumHeight(27);
    btnFind->setMaximumWidth(27);
    btnFind->setStyleSheet("background-image:url(:image/find.png);color:rgb(250,155,50);");
    QHBoxLayout *topLayout = new QHBoxLayout;
    topLayout->addWidget(labXuhao);
    topLayout->addWidget(txtXuhao);
    topLayout->addWidget(labTbfsa);
    topLayout->addWidget(txtTbfs);
    QHBoxLayout *bzaLayout = new QHBoxLayout;
    bzaLayout->addWidget(labBzxz);
    bzaLayout->addWidget(txtBzxz);
    bzaLayout->addWidget(labBcxz);
    bzaLayout->addWidget(txtBcxz);
    QHBoxLayout *ycLayout = new QHBoxLayout;
    ycLayout->addWidget(labDate);
    ycLayout->addWidget(txtDate);
    ycLayout->addWidget(labYc);
    ycLayout->addWidget(txtYc);
    ycLayout->addWidget(labYcDw);
    ycLayout->addStretch(1);
    QHBoxLayout *btnLayout = new QHBoxLayout;
    btnLayout->addWidget(labDataCount);
    //btnLayout->addWidget(btnFind);
    btnLayout->addWidget(btnFirst);
    btnLayout->addWidget(btnPrevious);
    btnLayout->addWidget(btnNext);
    btnLayout->addWidget(btnLast);
    btnLayout->addWidget(btnDel);

    QVBoxLayout *dataLayout = new QVBoxLayout;
    dataLayout->addLayout(topLayout);
    dataLayout->addSpacing(20);
    dataLayout->addLayout(bzaLayout);
    dataLayout->addSpacing(20);
    dataLayout->addLayout(ycLayout);
   // dataLayout->addSpacing(20);
    dataLayout->addStretch(1);
    dataLayout->addLayout(btnLayout);
    dataLayout->addSpacing(10);
    QHBoxLayout *wcDataLayout = new QHBoxLayout;
    wcDataLayout->addLayout(dataLayout);
    wcDataLayout->addWidget(tabWcData);
    widgetWcData->setLayout(wcDataLayout);

    widgetWc->setStyleSheet(".QLabel{min-height:37px;}");

    tabwc->addTab(widgetWc,tr("同步误差测量"));
    //LM 非同步误差测量
    f_wcPage = new F_WcPage;
    tabwc->addTab(f_wcPage->widgetWc,tr("非同步误差测量"));
    //LM 非同步测量
    connect(f_wcPage->list_action,SIGNAL(triggered()),this,SLOT(f_slotList()));
    connect(f_wcPage->scl_action,SIGNAL(triggered()),this,SLOT(f_slotScl()));
    //LM  非同步测量
    //LM 非同步误差测量

    tabwc->addTab(widgetWcData,tr("误差数据查询"));

//     SysPage *newSysPage=new SysPage;
//tabwc->addTab(newSysPage,tr("系统"));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(widgetLayout);
    mainLayout->addSpacing(5);

    mainLayout->addWidget(tabwc);

    mainLayout->setSpacing(0);
    mainLayout->addStretch(1);
 //   widget->setVisible(false);
    setLayout(mainLayout);
}
void TestPage::inittabWcData()
{
    tabWcData=new QTableView();
    QFont ft;
    ft.setPixelSize(17);
    ft.setBold(true);
    tabWcData->setFont(ft);
    tabWcData->setMinimumWidth(650);
  //  tabWc->setStyleSheet("color:rgb(250,0,255);");
    tabWcData->setAlternatingRowColors(true);
 //   tabWc->setStyleSheet("background-color:rgb(0,100,255);color:rgb(255,0,0);");
    // 由内容调整列 resizeColumnsToContents();
    tabWcData->setEditTriggers(QTableView::NoEditTriggers);//设置非编辑状态
    tabWcData->setSelectionBehavior(QTableView::SelectRows);//设置点击行为行
  //   tabWc->setSelectionBehavior(QTableView::SelectColumns);//设置点击行为列
  //   tabWc->setShowGrid(false);   //不显示中间的线
//     tabWc->setMaximumWidth(315);
   //  tabTd->setMinimumWidth(280);
 //    tabWc->setMaximumHeight(32);
/*
    QFont font=this->font();
    font.setPointSize(10);
    QStandardItemModel *model = new QStandardItemModel();
    QStandardItem* item1=new QStandardItem();
    item1->setFont(font);
    item1->setTextAlignment(Qt::AlignCenter);
    QStandardItem* item2=new QStandardItem();
    item2->setFont(font);
    item2->setTextAlignment(Qt::AlignCenter);
    QStandardItem* item3=new QStandardItem();
    item3->setFont(font);
    item3->setTextAlignment(Qt::AlignCenter);
    QStandardItem* item4=new QStandardItem();
    item4->setFont(font);
    item4->setTextAlignment(Qt::AlignCenter);
    QStandardItem* item5=new QStandardItem();
    item5->setFont(font);
    item5->setTextAlignment(Qt::AlignCenter);
    QStandardItem* item6=new QStandardItem();
    item6->setFont(font);
    item6->setTextAlignment(Qt::AlignCenter);

    item1->setText(tr("标准百分点"));
    item2->setText(tr("被测百分点"));
    item3->setText(tr("标准有效值"));
    item4->setText(tr("被测有效值"));
    item5->setText(tr("比差"));
    item6->setText(tr("角差"));

    QList<QStandardItem*> item;
    item << item1<< item2<< item3<< item4<< item5<< item6;
    model->appendRow(item);
*/
    model = new QStandardItemModel();
    model->setColumnCount(6);
    model->setHeaderData(0,Qt::Horizontal,tr("检定点"));
    model->setHeaderData(1,Qt::Horizontal,tr("被测百分点"));
    model->setHeaderData(2,Qt::Horizontal,tr("标准有效值"));
    model->setHeaderData(3,Qt::Horizontal,tr("被测有效值"));
    model->setHeaderData(4,Qt::Horizontal,tr("比差"));
    model->setHeaderData(5,Qt::Horizontal,tr("角差"));

  //  tabWc->horizontalHeader()->hide();
    tabWcData->verticalHeader()->hide();
    tabWcData->setModel(model);
    tabWcData->resizeColumnsToContents();

    tabWcData->setColumnWidth(0,90);
    tabWcData->setColumnWidth(1,85);
    tabWcData->setColumnWidth(2,130);
    tabWcData->setColumnWidth(3,130);
    tabWcData->setColumnWidth(4,100);
    tabWcData->setColumnWidth(5,100);
    tabWcData->setColumnHidden(1,true);
}
void TestPage::changeSty(int flag)
{
    QString sty,sty1;
    sty="pborder: 1px solid #636363;border-radius: 5px;adding:2px;background:none;selection-background-color:#4D4D4D;color:#FFFFFF;background-color:rgb(30,66,92)";
   //sty="border: 1px solid #636363;border-radius: 5px;padding:2px;background:none;selection-background-color:#4D4D4D;color:#AD0000;background-color:#00ADAD";
    if (flag==0)
    {
        sty1="background-color:rgb(18,29,34);border:0px;";
     //   sty="background-color:rgb(30,66,92);color:rgb(255,255,255);";
    }
    else if (flag==1)
    {
        sty1="background-color:rgb(255,255,255);border:0px;";
     //   sty="background-color:rgb(30,66,92);color:rgb(255,255,255);";
    //    sty="border: 1px solid #636363;border-radius: 5px;padding:2px;background:none;selection-background-color:#4D4D4D;color:#FFFFFF;background-color:rgb(30,66,92)";
    }
    else if (flag==2)
    {
        sty1="background-color:rgb(53,53,53);border:0px;";
   //     sty="background-color:rgb(30,66,92);color:rgb(255,255,255);";
    }
    else if (flag==3)
    {
        sty1="background-color:rgb(21,87,110);border:0px;";
      //  sty="background-color:rgb(30,66,92);color:rgb(255,255,255);";
    }
   // tabwc->setStyleSheet(sty1);
    cboTbfs->setStyleSheet(sty);
    cboBzSelect->setStyleSheet(sty);
    cboBcSelect->setStyleSheet(sty);
    cboBctd->setStyleSheet(sty);
    cboCTPT->setStyleSheet(sty);
    cboJD->setStyleSheet(sty);
    cboBhCl->setStyleSheet(sty);
    cboEdycDw->setStyleSheet(sty);
    cboCyfs->setStyleSheet(sty);
    cboSave->setStyleSheet(sty);
    txtEdyc->setStyleSheet(sty);
    txtBzXdy->setStyleSheet(sty);
    txtBcXdy->setStyleSheet(sty);
    txtMac->setStyleSheet(sty);
    txtTestNum->setStyleSheet(sty);
    btnGet->setStyleSheet(sty);
    cboInput->setStyleSheet(sty);
}

void TestPage::slotList()
{
    emit sigList();
}
void TestPage::slotScl()
{
    emit sigScl();
}

//LM 非同步测量
void TestPage::f_slotList()
{
    emit sigList();
}
void TestPage::f_slotScl()
{
    emit sigScl();
}
//LM 非同步测量
void TestPage::inittabTd()
{
    tabTd=new QTableView();
    QFont ft;
    ft.setPointSize(9);
    tabTd->setFont(ft);
    // 由内容调整列 resizeColumnsToContents();
     tabTd->setEditTriggers(QTableView::NoEditTriggers);//设置非编辑状态
  //   ui->tableView->setSelectionBehavior(QTableView::SelectRows);//设置点击行为行
     tabTd->setSelectionBehavior(QTableView::SelectColumns);//设置点击行为列
     tabTd->setShowGrid(false);   //不显示中间的线
     tabTd->setMaximumWidth(350);
     tabTd->setMinimumWidth(350);
     tabTd->setMaximumHeight(28);
     QStandardItemModel *model = new QStandardItemModel();
     for(int col=0;col<13;col++)
     {
        QStandardItem* item1=new QStandardItem();
        QFont font=this->font();
        font.setPointSize(10);
        item1->setFont(font);
        item1->setTextAlignment(Qt::AlignCenter);
        if(col==0)
        {
            item1->setText(tr("通道颜色"));
        }
        else
        {
            item1->setText(QString::number(col));
            switch(col)
            {
                case 1:
                   item1->setBackground(QColor(0X00,0X80,0X00));
                   break;
                case 2:
                   item1->setBackground(QColor(0X80,0X80,0X00));
                   break;
                case 3:
                   item1->setBackground(QColor(0X00,0X00,0X80));
                   break;
                case 4:
                   item1->setBackground(QColor(0X80,0X00,0X80));
                   break;
                case 5:
                   item1->setBackground(QColor(0X00,0X80,0X80));
                   break;
                case 6:
                   item1->setBackground(QColor(0X80,0X80,0X80));
                   break;
                case 7:
                   item1->setBackground(QColor(0XC0,0XC0,0XC0));
                   break;
                case 8:
                   item1->setBackground(QColor(0XFF,0X00,0X00));
                   break;
                case 9:
                   item1->setBackground(QColor(0X00,0XFF,0X00));
                   break;
                case 10:
                   item1->setBackground(QColor(0XFF,0XFF,0X00));
                   break;
                case 11:
                   item1->setBackground(QColor(0X00,0X00,0XFF));
                   break;
                case 12:
                   item1->setBackground(QColor(0XFF,0X00,0XFF));
                   break;
                }
             }
             QList<QStandardItem*> item;
             item << item1;
             model->appendColumn(item);
         }
     tabTd->horizontalHeader()->hide();
     tabTd->verticalHeader()->hide();
     tabTd->setModel(model);
   //  tabTd->resizeColumnsToContents();
     tabTd->setColumnWidth(0,70);
     for(int i=1;i<13;i++)
       tabTd->setColumnWidth(i,22);
}

LuboPage::LuboPage(QWidget *parent)
    : QWidget(parent)
{
    QFont ft;
    ft.setPointSize(9);
    ft.setBold(true);
    labBt=new QLabel(tr("    解析结果 :"));
    txtLubo=new QTextEdit();

    QLabel *blackLabel = new QLabel(this);
    blackLabel->setFixedWidth(40);
//    blackLabel->setStyleSheet("background-color: yellow");

    QFont ft_for_table;
    ft_for_table.setPixelSize(14);

    smvTree = new QTreeView;
    smvTree->setFont(ft_for_table);
    smvTree->header()->setFont(ft_for_table);

    smvTree->setStyleSheet(
                "QTreeView {"
                "background-color: white;"
                "}"
                "QTreeview::item {"
                "background-color: white;"
                "}"
                "QHeaderView::section {"
                "background-color: gray;"
                "}"
                "QScrollBar{"
                "background:#bbb; width: 20px;"
                "}"
                );

    QStandardItemModel *show_protocol = new QStandardItemModel();
    show_protocol->setColumnCount(3);
    show_protocol->setRowCount(0);
    show_protocol->setHeaderData(0,Qt::Horizontal,tr("Name"));
    show_protocol->setHeaderData(1,Qt::Horizontal,tr("Data"));
    show_protocol->setHeaderData(2,Qt::Horizontal,tr("Value"));
    smvTree->setModel(show_protocol);

    smvTree->setColumnWidth(0,130);
    smvTree->setColumnWidth(1,170);
    smvTree->setColumnWidth(2,170);

    QList<QStandardItem *> items0;

    QStandardItem *item0 = new QStandardItem(QString("协议类型"));
    items0.append(item0);
    QStandardItem *item1 = new QStandardItem(QString("9-2 LE"));
    items0.append(item1);

    show_protocol->appendRow(items0);

    QList<QStandardItem *> items1;

    QStandardItem *item10 = new QStandardItem(QString("目的MAC"));
    items1.append(item10);
    QStandardItem *item11 = new QStandardItem(QString("0x00000000"));
    items1.append(item11);
    QStandardItem *item12 = new QStandardItem(QString("0:0:0:0:0:0"));
    items1.append(item12);

    show_protocol->appendRow(items1);

    QList<QStandardItem *> items2;

    QStandardItem *item20 = new QStandardItem(QString("设备MAC"));
    items2.append(item20);
    QStandardItem *item21 = new QStandardItem(QString("0x00000000"));
    items2.append(item21);
    QStandardItem *item22 = new QStandardItem(QString("0:0:0:0:0:0"));
    items2.append(item22);
    show_protocol->appendRow(items2);

    QList<QStandardItem *> items3;
    QStandardItem *item30 = new QStandardItem(QString("VLAN"));
    items3.append(item30);
    QStandardItem *item31 = new QStandardItem(QString(" "));
    items3.append(item31);
    QStandardItem *item32 = new QStandardItem(QString("无"));
    items3.append(item32);

    show_protocol->appendRow(items3);

    QList<QStandardItem *> items;

    QStandardItem *item = new QStandardItem(QString("ASDU"));

    items.append(item);
    show_protocol->appendRow(items);

    QList<QStandardItem *> childItems0;

    QStandardItem *childItems00 = new QStandardItem(QString("SmpCnt"));
    childItems0.append(childItems00);

    QStandardItem *childItems01 = new QStandardItem(QString("0x0001"));
    childItems0.append(childItems01);

    QStandardItem *childItems02 = new QStandardItem(QString("1"));
    childItems0.append(childItems02);

    items.at(0)->appendRow(childItems0);

    QList<QStandardItem *> childItems1;

    QStandardItem *childItems10 = new QStandardItem(QString("SvID"));
    childItems1.append(childItems10);

    QStandardItem *childItems11 = new QStandardItem(QString("0x6162623030"));
    childItems1.append(childItems11);

    QStandardItem *childItems12 = new QStandardItem(QString("abb00"));
    childItems1.append(childItems12);

    items.at(0)->appendRow(childItems1);

//    QStandardItemModel *show_protocol2 = new QStandardItemModel();
//    show_protocol2->setColumnCount(3);
//    show_protocol2->setRowCount(0);
//    show_protocol2->setHeaderData(0,Qt::Horizontal,tr("Name"));
//    show_protocol2->setHeaderData(1,Qt::Horizontal,tr("Data"));
//    show_protocol2->setHeaderData(2,Qt::Horizontal,tr("Value"));
//    table->setModel(show_protocol2);

    QHBoxLayout *layoutForTable = new QHBoxLayout;
    layoutForTable->setContentsMargins(0,2,0,0);
    layoutForTable->addWidget(smvTree);
    layoutForTable->addWidget(blackLabel);

    QWidget *widgetForTable = new QWidget;
    widgetForTable->setLayout(layoutForTable);
    widgetForTable->setFixedSize(550,150);

    ft.setPointSize(9);
    labBt->setFont(ft);
    labBt->setStyleSheet("color:rgb(250,155,50);");
  //  txtLubo->setFont(ft);
//    txtLubo->setMinimumHeight(100);
//    txtLubo->setMinimumWidth(130);
    txtLubo->setFixedSize(500,100);
    txtLubo->setStyleSheet(
                "QTextEdit{"
                "background-color: white;"
                "color:black;"
                "font-size:15px;"
                "}"
                "QScrollBar{"
                "background:#bbb; width: 20px;"
                "}"
                );

    txtLuboTime=new QLineEdit("1");
    txtLuboTime->setMaximumWidth(100);

    combLuboTime = new QComboBox;
    setView(combLuboTime);
    combLuboTime->setMinimumWidth(100);
    combLuboTime->addItem("1 秒");
    combLuboTime->addItem("2 秒");
    combLuboTime->addItem("3 秒");
    combLuboTime->addItem("4 秒");
    combLuboTime->addItem("5 秒");

    QLabel *labLbTime=new QLabel(tr("录波时长(秒)"));

    rdoAll=new QRadioButton(tr("全部周期波形"));
    rdoOne=new QRadioButton(tr("单个周期波形"));
    rdoAll->setChecked(true);

    chkSelectAll=new QCheckBox(tr("显示所有"));
    ft.setPointSize(12);
    chkSelectAll->setFont(ft);
    chkSelectAll->setStyleSheet("color:#FFFFFF");
  //  chkSelectAll->setCheckState(Qt::Checked);
    chkSelectAll->setChecked(true);
    btnLuboData=new QPushButton(tr("查看录波记录"));

    ft.setPointSize(9);
    ft.setBold(false);
    lblY_1=new QLabel(tr("|"));
    lblY_2=new QLabel(tr("|"));
    lblY_3=new QLabel(tr("|"));
    lblY_4=new QLabel(tr("|"));
    lblY_5=new QLabel(tr("|"));
    lblY_6=new QLabel(tr("|"));
    lblY_7=new QLabel(tr("|"));
    lblY_8=new QLabel(tr("|"));
    lblY_9=new QLabel(tr("|"));
    lblY_10=new QLabel(tr("|"));
    lblY_11=new QLabel(tr("|"));
    lblY_12=new QLabel(tr("|"));
    lblY_13=new QLabel(tr("|"));
    lblY_14=new QLabel(tr("|"));
    lblY_15=new QLabel(tr("|"));
    lblY_16=new QLabel(tr("|"));
    lblY_1->setFont(ft);
    lblY_2->setFont(ft);
    lblY_3->setFont(ft);
    lblY_4->setFont(ft);
    lblY_5->setFont(ft);
    lblY_6->setFont(ft);
    lblY_7->setFont(ft);
    lblY_8->setFont(ft);
    lblY_9->setFont(ft);
    lblY_10->setFont(ft);
    lblY_11->setFont(ft);
    lblY_12->setFont(ft);
    lblY_13->setFont(ft);
    lblY_14->setFont(ft);
    lblY_15->setFont(ft);
    lblY_16->setFont(ft);

    lblYY[0]=new QLabel(tr("0.01"));
    lblYY[1]=new QLabel(tr("0.02"));
    lblYY[2]=new QLabel(tr("0.03"));
    lblYY[3]=new QLabel(tr("0.04"));
    lblYY[4]=new QLabel(tr("0.05"));
    lblYY[5]=new QLabel(tr("0.06"));
    lblYY[6]=new QLabel(tr("0.07"));
    lblYY[7]=new QLabel(tr("0.08"));
    lblYY[8]=new QLabel(tr("0.09"));
    lblYY[9]=new QLabel(tr("0.10"));
    lblYY[10]=new QLabel(tr("0.11"));
    lblYY[11]=new QLabel(tr("0.12"));
    lblYY[12]=new QLabel(tr("0.13"));
    lblYY[13]=new QLabel(tr("0.14"));
    lblYY[14]=new QLabel(tr("0.15"));
    lblYY[15]=new QLabel(tr("0.16"));
    for(int i=0;i<16;i++)
    {
        lblYY[i]->setFont(ft);
        lblYY[i]->setVisible(false);
    }

    ft.setPointSize(9);
    ft.setBold(true);
    scrllCurve=new QScrollBar(Qt::Horizontal);
    tSlider=new QSlider(Qt::Horizontal);
    tSlider->setRange(0,200);
    /*
    widget=new QWidget();
    widget->setStyleSheet("background-color:#000000");
    widget->setMaximumHeight(220);
    widget->setMinimumHeight(220);
    widget->setMinimumWidth(460);
*/
    labColor1=new ClickedLabel();
    labColor1->setText("1");
    labColor1->setFont(ft);
    labColor1->setAlignment(Qt::AlignCenter);
    labColor1->setMaximumWidth(25);
    labColor1->setMaximumHeight(25);
    labColor1->setStyleSheet("background-color:#008000");
    labColor2=new ClickedLabel();
    labColor2->setText("2");
    labColor2->setFont(ft);
    labColor2->setAlignment(Qt::AlignCenter);
    labColor2->setMaximumWidth(25);
    labColor2->setMaximumHeight(25);
    labColor2->setStyleSheet("background-color:#808000");
    labColor3=new ClickedLabel();
    labColor3->setText("3");
    labColor3->setFont(ft);
    labColor3->setAlignment(Qt::AlignCenter);
    labColor3->setMaximumWidth(25);
    labColor3->setMaximumHeight(25);
    labColor3->setStyleSheet("background-color:#000080");
    labColor4=new ClickedLabel();
    labColor4->setText("4");
    labColor4->setFont(ft);
    labColor4->setAlignment(Qt::AlignCenter);
    labColor4->setMaximumWidth(25);
    labColor4->setMaximumHeight(25);
    labColor4->setStyleSheet("background-color:#800080");
    labColor5=new ClickedLabel();
    labColor5->setText("5");
    labColor5->setFont(ft);
    labColor5->setAlignment(Qt::AlignCenter);
    labColor5->setMaximumWidth(25);
    labColor5->setMaximumHeight(25);
    labColor5->setStyleSheet("background-color:#008080");
    labColor6=new ClickedLabel();
    labColor6->setText("6");
    labColor6->setFont(ft);
    labColor6->setAlignment(Qt::AlignCenter);
    labColor6->setMaximumWidth(25);
    labColor6->setMaximumHeight(25);
    labColor6->setStyleSheet("background-color:#808080");
    labColor7=new ClickedLabel();
    labColor7->setText("7");
    labColor7->setFont(ft);
    labColor7->setAlignment(Qt::AlignCenter);
    labColor7->setMaximumWidth(25);
    labColor7->setMaximumHeight(25);
    labColor7->setStyleSheet("background-color:#C0C0C0");
    labColor8=new ClickedLabel();
    labColor8->setText("8");
    labColor8->setFont(ft);
    labColor8->setAlignment(Qt::AlignCenter);
    labColor8->setMaximumWidth(25);
    labColor8->setMaximumHeight(25);
    labColor8->setStyleSheet("background-color:#FF0000");
    labColor9=new ClickedLabel();
    labColor9->setText("9");
    labColor9->setFont(ft);
    labColor9->setAlignment(Qt::AlignCenter);
    labColor9->setMaximumWidth(25);
    labColor9->setMaximumHeight(25);
    labColor9->setStyleSheet("background-color:#00FF00");
    labColor10=new ClickedLabel();
    labColor10->setText("10");
    labColor10->setFont(ft);
    labColor10->setAlignment(Qt::AlignCenter);
    labColor10->setMaximumWidth(25);
    labColor10->setMaximumHeight(25);
    labColor10->setStyleSheet("background-color:#FFFF00");
    labColor11=new ClickedLabel();
    labColor11->setText("11");
    labColor11->setFont(ft);
    labColor11->setAlignment(Qt::AlignCenter);
    labColor11->setMaximumWidth(25);
    labColor11->setMaximumHeight(25);
    labColor11->setStyleSheet("background-color:#0000FF");
    labColor12=new ClickedLabel();
    labColor12->setText("12");
    labColor12->setFont(ft);
    labColor12->setAlignment(Qt::AlignCenter);
    labColor12->setMaximumWidth(25);
    labColor12->setMaximumHeight(25);
    labColor12->setStyleSheet("background-color:#FF00FF");

    QHBoxLayout *dsLayout = new QHBoxLayout;
    dsLayout->addWidget(lblY_1);
    dsLayout->addWidget(lblY_2);
    dsLayout->addWidget(lblY_3);
    dsLayout->addWidget(lblY_4);
    dsLayout->addWidget(lblY_5);
    dsLayout->addWidget(lblY_6);
    dsLayout->addWidget(lblY_7);
    dsLayout->addWidget(lblY_8);
    dsLayout->addWidget(lblY_9);
    dsLayout->addWidget(lblY_10);
    dsLayout->addWidget(lblY_11);
    dsLayout->addWidget(lblY_12);
    dsLayout->addWidget(lblY_13);
    dsLayout->addWidget(lblY_14);
    dsLayout->addWidget(lblY_15);
    dsLayout->addWidget(lblY_16);
    lblY_1->setVisible(false);
    lblY_2->setVisible(false);
    lblY_3->setVisible(false);
    lblY_4->setVisible(false);
    lblY_5->setVisible(false);
    lblY_6->setVisible(false);
    lblY_7->setVisible(false);
    lblY_8->setVisible(false);
    lblY_9->setVisible(false);
    lblY_10->setVisible(false);
    lblY_11->setVisible(false);
    lblY_12->setVisible(false);
    lblY_13->setVisible(false);
    lblY_14->setVisible(false);
    lblY_15->setVisible(false);
    lblY_16->setVisible(false);
    QHBoxLayout *dyLayout = new QHBoxLayout;
    for(int i=0;i<16;i++)
         dyLayout->addWidget(lblYY[i]);

    QLabel *labNo=new QLabel("");
    labNo->setMinimumWidth(60);
    QHBoxLayout *widLayout = new QHBoxLayout;
  //  widLayout->addWidget(widget);
    widLayout->addWidget(labNo);

    QVBoxLayout *leftLayout = new QVBoxLayout;
    leftLayout->addWidget(txtLubo);
//    leftLayout->addWidget(labBt);
    leftLayout->addWidget(widgetForTable);
 //   QHBoxLayout *boLayout = new QHBoxLayout;
    QVBoxLayout *boLayout = new QVBoxLayout;
    boLayout->addWidget(scrllCurve);
    boLayout->addWidget(tSlider);
 //   boLayout->addWidget(rdoAll);
 //   boLayout->addWidget(rdoOne);
    QVBoxLayout *midLayout = new QVBoxLayout;
 //   midLayout->addWidget(widget);
    midLayout->addLayout(widLayout);
    midLayout->addLayout(dsLayout);
    midLayout->addLayout(dyLayout);
    midLayout->addLayout(boLayout);

    QHBoxLayout *ysLayout = new QHBoxLayout;
    ysLayout->addWidget(chkSelectAll);
    ysLayout->addWidget(labColor1);
    ysLayout->addWidget(labColor2);
    ysLayout->addWidget(labColor3);
    ysLayout->addWidget(labColor4);
    ysLayout->addWidget(labColor5);
    ysLayout->addWidget(labColor6);
    ysLayout->addWidget(labColor7);
    ysLayout->addWidget(labColor8);
    ysLayout->addWidget(labColor9);
    ysLayout->addWidget(labColor10);
    ysLayout->addWidget(labColor11);
    ysLayout->addWidget(labColor12);
  //  rightLayout->addStretch(1);

    QHBoxLayout *szLayout = new QHBoxLayout;
    szLayout->addWidget(labLbTime);
    //szLayout->addWidget(txtLuboTime);
    szLayout->addWidget(combLuboTime);
    szLayout->addStretch(1);
    szLayout->addWidget(btnLuboData);


    midLayout->addLayout(ysLayout);
    midLayout->addLayout(szLayout);

    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->addLayout(leftLayout);
    mainLayout->addLayout(midLayout);
  //  mainLayout->addLayout(rightLayout);
  //  mainLayout->addStretch(1);
    setLayout(mainLayout);
}
SysPage::SysPage(QWidget *parent)
    : QWidget(parent)
{
    QFont ft;
    ft.setPointSize(10);
    ft.setBold(true);
    tabWidget=new QTabWidget();
    tabWidget->setTabPosition(QTabWidget::South);
    tabWidget->setMinimumHeight(250);
    tabWidget->setFont(ft);
    ft.setPointSize(12);
    ft.setBold(true);
   // tabWidget->setStyleSheet("border-image:url(:image/bj-1.jpg);color:rgb(50,55,50);");
    QGroupBox *boxGuiyue=new QGroupBox(tr(""));

    txtBCCYSL=new QLineEdit();
    txtBCCYSL->setFont(ft);
    txtBCCYSL->setMaximumWidth(100);
    txtBCCYSL->setStyleSheet("color:rgb(250,155,50);");
  //  txtBCCYSL->setMaximum(500);

    inittab();
    ft.setPointSize(10);
    labGuiyuecanshu=new QLabel(tr("规约参数:"));
    QLabel *labGuiyuename=new QLabel(tr("9-2规约采样速率(被测)"));
    labGuiyuecanshu->setFont(ft);
    labGuiyuecanshu->setStyleSheet("color:rgb(250,155,0);");
    labGuiyuecanshu->setMaximumWidth(110);
    labGuiyuename->setFont(ft);
    labGuiyuename->setStyleSheet("color:rgb(250,155,50);");
    QLabel *labDatatime=new QLabel(tr("数据包时序:"));
    labDatatime->setFont(ft);
  //  labDatatime->setStyleSheet("color:rgb(250,155,50);");
    cboDatatime=new QComboBox();
    setView(cboDatatime);
    cboDatatime->addItem(tr("标准与被测在同一秒"));
    cboDatatime->addItem(tr("标准比被测慢了一秒"));
    cboDatatime->addItem(tr("标准比被测快了一秒"));
    cboDatatime->setMinimumSize(180,20);
    cboDatatime->setFont(ft);
 //   cboDatatime->setStyleSheet("color:rgb(250,155,50);");

    QLabel *labSysXs=new QLabel(tr("有效值稳定性百分数(%):"));
    labSysXs->setFont(ft);
 //   labSysXs->setStyleSheet("color:rgb(250,155,50);");
    txtSysXs=new QLineEdit();
    txtSysXs->setMaximumWidth(140);
    txtSysXs->setFont(ft);
//    txtSysXs->setStyleSheet("color:rgb(250,155,50);");
    QLabel *labSysBc=new QLabel(tr("比差稳定性百分数(%):"));
    labSysBc->setFont(ft);
 //   labSysBc->setStyleSheet("color:rgb(250,155,50);");
    txtSysBc=new QLineEdit();
    txtSysBc->setMaximumWidth(170);
    txtSysBc->setFont(ft);
 //   txtSysBc->setStyleSheet("color:rgb(250,155,50);");
    QLabel *labSysJc=new QLabel(tr("角差稳定性系数('):"));
    labSysJc->setFont(ft);
//    labSysJc->setStyleSheet("color:rgb(250,155,50);");
    txtSysJc=new QLineEdit();
    txtSysJc->setMaximumWidth(170);
    txtSysJc->setFont(ft);
 //   txtSysJc->setStyleSheet("color:rgb(250,155,50);");
    QLabel *labSysSf=new QLabel(tr("算法选择:"));
    labSysSf->setFont(ft);
 //   labSysSf->setStyleSheet("color:rgb(250,155,50);");
    cboSysSf=new QComboBox();
    setView(cboSysSf);
    cboSysSf->addItem(tr("傅利叶算法"));
    cboSysSf->addItem(tr("加窗算法"));
    cboSysSf->setMinimumWidth(200);
    cboSysSf->setFont(ft);
    cboSysSf->setCurrentIndex(1);
  //  cboSysSf->setStyleSheet("color:rgb(250,155,50);");

    QHBoxLayout *mLayout = new QHBoxLayout;
    mLayout->addWidget(labSysXs);
    mLayout->addWidget(txtSysXs);
    mLayout->addStretch(1);
    QHBoxLayout *m1Layout = new QHBoxLayout;
    m1Layout->addWidget(labSysBc);
    m1Layout->addWidget(txtSysBc);
    m1Layout->addStretch(1);
    QHBoxLayout *m2Layout = new QHBoxLayout;
    m2Layout->addWidget(labSysJc);
    m2Layout->addWidget(txtSysJc);
    m2Layout->addStretch(1);
    QHBoxLayout *m3Layout = new QHBoxLayout;
    m3Layout->addWidget(labSysSf);
    m3Layout->addWidget(cboSysSf);
    m3Layout->addStretch(1);

    QHBoxLayout *labLayout = new QHBoxLayout;
    labLayout->addWidget(labGuiyuename);
   // labLayout->addWidget(spiBCCYSL);
    labLayout->addWidget(txtBCCYSL);
    labLayout->addStretch(1);

    QHBoxLayout *lLayout = new QHBoxLayout;
    lLayout->addWidget(labDatatime);
    lLayout->addWidget(cboDatatime);
    lLayout->addStretch(1);
 //---------------------
    labGuiyuecanshu->setText(tr("报文参数:"));
//----------------------
    QVBoxLayout *oneLayout = new QVBoxLayout;

  //  oneLayout->addStretch(1);
    oneLayout->addWidget(labGuiyuecanshu);
    oneLayout->addWidget(tabMU);
    /*
    oneLayout->addLayout(labLayout);
    oneLayout->addLayout(lLayout);
    oneLayout->addLayout(mLayout);
    oneLayout->addLayout(m1Layout);
    oneLayout->addLayout(m2Layout);
    oneLayout->addLayout(m3Layout);
    oneLayout->addStretch(1);
    */
    boxGuiyue->setLayout(oneLayout);

    QVBoxLayout *twoLayout = new QVBoxLayout;
    twoLayout->addLayout(lLayout);
    twoLayout->addLayout(mLayout);
    twoLayout->addLayout(m1Layout);
    twoLayout->addLayout(m2Layout);
    //twoLayout->addLayout(m3Layout);
    twoLayout->addStretch(1);

    widgetSetup=new QWidget();
    widgetSetup->setLayout(twoLayout);

   // ft.setPointSize(14);
    labMima=new QLabel(tr("请输入管理员密码："));
    labMima->setFont(ft);
    txtMima=new QLineEdit();
    txtMima->setFont(ft);

    btnEnter=new QPushButton(tr("进入"));

    tabSys=new QTabWidget();
    tabSys->setMinimumHeight(270);
 //   tabSys->setTabPosition(QTabWidget::West);
    tabCsbc=new QTableView();
    ft.setPointSize(10);
    ft.setBold(true);
    tabCsbc->setFont(ft);
  //  tabCsbc->setSelectionBehavior(QTableView::SelectRows);//设置点击行为行
    model = new QStandardItemModel();
    model->setColumnCount(7);
    model->setRowCount(0);
    model->setHeaderData(0,Qt::Horizontal,tr("标准-被测"));
    model->setHeaderData(1,Qt::Horizontal,tr("2%以下比差补偿"));
    model->setHeaderData(2,Qt::Horizontal,tr("2%以下角差补偿"));
    model->setHeaderData(3,Qt::Horizontal,tr("2-10%比差补偿"));
    model->setHeaderData(4,Qt::Horizontal,tr("2-10%角差补偿"));
    model->setHeaderData(5,Qt::Horizontal,tr("10%以上比差补偿"));
    model->setHeaderData(6,Qt::Horizontal,tr("10%以上角差补偿"));

  //  tabWc->horizontalHeader()->hide();
    tabCsbc->verticalHeader()->hide();
    tabCsbc->setModel(model);
    tabCsbc->resizeColumnsToContents();
    tabCsbc->setColumnWidth(0,150);
    tabCsbc->setColumnWidth(1,120);
    tabCsbc->setColumnWidth(2,120);
    tabCsbc->setColumnWidth(3,120);
    tabCsbc->setColumnWidth(4,120);
    tabCsbc->setColumnWidth(5,120);
    tabCsbc->setColumnWidth(6,120);

    widgetSysbc=new QWidget();
    cboBzbc=new QComboBox();
    setView(cboBzbc);
    cboBzbc->setMinimumWidth(200);
    cboBzbc->addItem(tr("5A-5A"));
    cboBzbc->addItem(tr("1A-1A"));
    cboBzbc->addItem(tr("5A-模拟小电压"));
    cboBzbc->addItem(tr("1A-模拟小电压"));
    cboBzbc->addItem(tr("100V或100/√3V-模拟小电压"));
    cboBzbc->addItem(tr("模拟小电压-模拟小电压"));
    cboBzbc->addItem(tr("5A-数字量"));
    cboBzbc->addItem(tr("1A-数字量"));
    cboBzbc->addItem(tr("100V或100/√3V-数字量"));
    cboBzbc->addItem(tr("模拟小电压-数字量"));
    cboBzbc->addItem(tr("100V-100V"));
    cboBzbc->addItem(tr("100/√3V-100/√3V"));
    cboBzbc->setFont(ft);
    txtbc=new QLineEdit();
    txtbc1=new QLineEdit();
    txtbc2=new QLineEdit();
    txtbc3=new QLineEdit();
    txtjc=new QLineEdit();
    txtjc1=new QLineEdit();
    txtjc2=new QLineEdit();
    txtjc3=new QLineEdit();
    txtbc->setFont(ft);
    txtbc->setMinimumWidth(150);
    txtbc1->setFont(ft);
    txtbc1->setMinimumWidth(150);
    txtbc2->setFont(ft);
    txtbc2->setMinimumWidth(150);
    txtbc3->setFont(ft);
    txtbc3->setMinimumWidth(150);
    txtjc->setFont(ft);
    txtjc->setMinimumWidth(150);
    txtjc1->setFont(ft);
    txtjc1->setMinimumWidth(150);
    txtjc2->setFont(ft);
    txtjc2->setMinimumWidth(150);
    txtjc3->setFont(ft);
    txtjc3->setMinimumWidth(150);
    QLabel *labBzbc=new QLabel(tr("标准-被测"));
    QLabel *labBicha=new QLabel(tr("比差补偿(%)"));
    QLabel *labJiaocha=new QLabel(tr("角差补偿(')"));
    QLabel *labbc=new QLabel(tr("总体"));
    QLabel *labbc1=new QLabel(tr("2%以下"));
    QLabel *labbc2=new QLabel(tr("2-10%以下"));
    QLabel *labbc3=new QLabel(tr("10%以上"));
    QLabel *labkb=new QLabel(tr(""));
    labBzbc->setFont(ft);
    labBzbc->setMinimumWidth(150);
    labBzbc->setMaximumWidth(150);
    labBicha->setFont(ft);
    labBicha->setMinimumWidth(150);
    labBicha->setMaximumWidth(150);
    labJiaocha->setFont(ft);
    labJiaocha->setMinimumWidth(150);
    labJiaocha->setMaximumWidth(150);
    labbc->setFont(ft);
    labbc->setMinimumWidth(170);
    labbc->setMaximumWidth(170);
    labbc1->setFont(ft);
    labbc1->setMinimumWidth(170);
    labbc1->setMaximumWidth(170);
    labbc2->setFont(ft);
    labbc2->setMinimumWidth(150);
    labbc2->setMaximumWidth(150);
    labbc3->setFont(ft);
    labbc3->setMinimumWidth(150);
    labbc3->setMaximumWidth(150);
    labkb->setFont(ft);
    labkb->setMinimumWidth(150);
    labkb->setMaximumWidth(150);

    QHBoxLayout *sbzbcLayout = new QHBoxLayout;
    sbzbcLayout->addWidget(labBzbc);
    sbzbcLayout->addWidget(cboBzbc);
    sbzbcLayout->addStretch(1);

    QHBoxLayout *sbc1 = new QHBoxLayout;
    sbc1->addWidget(labkb);
    sbc1->addWidget(labbc);
    sbc1->addWidget(labbc1);
    sbc1->addWidget(labbc2);
    sbc1->addWidget(labbc3);
    sbc1->addStretch(1);

    QHBoxLayout *sbc2 = new QHBoxLayout;
    sbc2->addWidget(labBicha);
    sbc2->addWidget(txtbc);
    sbc2->addWidget(txtbc1);
    sbc2->addWidget(txtbc2);
    sbc2->addWidget(txtbc3);
    sbc2->addStretch(1);

    QHBoxLayout *sbc3 = new QHBoxLayout;
    sbc3->addWidget(labJiaocha);
    sbc3->addWidget(txtjc);
    sbc3->addWidget(txtjc1);
    sbc3->addWidget(txtjc2);
    sbc3->addWidget(txtjc3);
    sbc3->addStretch(1);
    QVBoxLayout *sbc = new QVBoxLayout;
    sbc->addLayout(sbzbcLayout);
    sbc->addLayout(sbc1);
    sbc->addLayout(sbc2);
    sbc->addLayout(sbc3);
    sbc->addStretch(1);
    widgetSysbc->setLayout(sbc);

    tabSys->addTab(widgetSysbc,tr("补偿数据"));
    tabSys->addTab(widgetSetup,tr("测量参数设定"));
  //  tabSys->addTab(tabCsbc,tr("补偿数据"));


   // boxBc=new QGroupBox();
    widgetBc=new QWidget();

    labBcbc=new QLabel(" ");
    labJcbc=new QLabel(tr("角差补偿(')"));
    txtBcbc=new QLineEdit();
    txtJcbc=new QLineEdit();
    btnBc=new QPushButton(tr("保存"));
    btnBc->setFont(ft);
    btnBc->setMinimumWidth(50);
 //   labMima->setFont(ft);
 //   labMima->setStyleSheet("color:rgb(250,155,50);");
    labBcbc->setFont(ft);
 //   labBcbc->setStyleSheet("color:rgb(250,155,50);");
    labJcbc->setFont(ft);
  //  labJcbc->setStyleSheet("color:rgb(250,155,50);");
    btnEnter->setMaximumWidth(100);
//    btnEnter->setMinimumHeight(60);
    btnEnter->setFont(ft);

    btnSysSave=new QPushButton(tr("保存"));
    btnSysSave->setMinimumWidth(100);
    btnSysSave->setMinimumHeight(60);
    btnSysSave->setFont(ft);
 //   btnEnter->setStyleSheet("background-image:url(:image/bj-1.jpg);color:rgb(250,155,50);");
 //   txtMima->setFont(ft);
 //   txtMima->setStyleSheet("color:rgb(250,155,50);");
   // txtMima->setMaximumWidth(220);
    txtMima->setMinimumWidth(210);
    txtMima->setEchoMode(QLineEdit::Password);    
    txtBcbc->setFont(ft);
   // txtBcbc->setStyleSheet("color:rgb(255,0,0);");
    txtBcbc->setMaximumWidth(200);
    txtJcbc->setFont(ft);
  //  txtJcbc->setStyleSheet("color:rgb(255,0,0);");
    txtJcbc->setMaximumWidth(200);
  //  labBcbc->setVisible(false);
    labJcbc->setVisible(false);
    txtBcbc->setVisible(false);
    txtJcbc->setVisible(false);
    tabSys->setVisible(false);
    btnSysSave->setVisible(false);
    btnBc->setVisible(false);
    QHBoxLayout *sysLayout = new QHBoxLayout;
    sysLayout->addWidget(labMima);
    sysLayout->addWidget(txtMima);
    sysLayout->addWidget(btnEnter);
    sysLayout->addStretch(1);
    QVBoxLayout *sys1Layout = new QVBoxLayout;
    sys1Layout->addLayout(sysLayout);
  //  sys1Layout->addWidget(btnEnter);
    QHBoxLayout *bcbcLayout = new QHBoxLayout;
    bcbcLayout->addWidget(labBcbc);
    bcbcLayout->addWidget(txtBcbc);
    bcbcLayout->addWidget(btnBc);
    bcbcLayout->addStretch(1);

    QVBoxLayout *baLayout = new QVBoxLayout;
    baLayout->addStretch(1);
    baLayout->addWidget(btnSysSave);
    QHBoxLayout *bbLayout = new QHBoxLayout;
    bbLayout->addWidget(tabSys);
    bbLayout->addLayout(baLayout);

    QHBoxLayout *jcbcLayout = new QHBoxLayout;
    jcbcLayout->addWidget(labJcbc);
    jcbcLayout->addSpacing(1);
    jcbcLayout->addWidget(txtJcbc);
    jcbcLayout->addStretch(1);
    sys1Layout->addLayout(bbLayout);
    sys1Layout->addLayout(bcbcLayout);
 //   sys1Layout->addLayout(jcbcLayout);

 //   boxBc->setLayout(sys1Layout);
    widgetBc->setLayout(sys1Layout);
    ft.setPointSize(12);
    //  QLabel *labCcbh=new QLabel(tr("出厂编号:1387048"));//
      labCcbh=new QLabel("");
      labCcbh->setFont(ft);
     // labCcbh->setStyleSheet("color:rgb(250,155,50);");
      labHardware=new QLabel(tr(""));;
      labHardware->setFont(ft);
   //   labHardware->setStyleSheet("color:rgb(250,155,50);");
      labSoftware=new QLabel(tr(""));
      labSoftware->setFont(ft);
   //   labSoftware->setStyleSheet("color:rgb(250,155,50);");

      BLDG=true;
      /*
    BLDG=false;
    QString sPath=QCoreApplication::applicationDirPath();
    QString sfile=sPath +"/"+ tr("info");
    if (!QFile::exists(sfile))
    {
        labCcbh->setText(tr("出厂编号:1211024"));
        labHardware->setText(tr("硬件版本号：V1.0.300"));
        labSoftware->setText(tr("软件版本号：V1.0.305"));
    }
    else
    {
        QFile file(sfile);
        if (file.open(QIODevice::ReadOnly))
        {
            QString sText=file.readAll();
            char charSplit=0X0A;
            QStringList sPoints=sText.split(charSplit);
            labCcbh->setText(sPoints.at(0));            
            labHardware->setText(sPoints.at(1));
            QString s=sPoints.at(2);
            labSoftware->setText(s);
            charSplit='V';
            sPoints=s.split(charSplit);
            if (sPoints.at(1)=="2.0")
                BLDG=false;
            else
                BLDG=true;
        }
        else
        {
            labCcbh->setText(tr("出厂编号:1211024"));
            labHardware->setText(tr("硬件版本号：V1.0.300"));
            labSoftware->setText(tr("软件版本号：V1.0.305"));
        }
        file.close();
    }
*/
  //  boxInfo=new QGroupBox();
    widgetInfo=new QWidget();

    QVBoxLayout *sys2Layout = new QVBoxLayout;
    btnSystoUpdate=new QPushButton(tr("系统升级"));
    btnSystoUpdate->setFont(ft);
    btnSystoUpdate->setMaximumWidth(100);
    btnSystoUpdate->setStyleSheet("color:rgb(250,155,50);");
    sys2Layout->addWidget(labCcbh);
    sys2Layout->addWidget(labHardware);
    sys2Layout->addWidget(labSoftware);
    sys2Layout->addWidget(btnSystoUpdate);
    sys2Layout->addStretch(1);
  //  boxInfo->setLayout(sys2Layout);
    widgetInfo->setLayout(sys2Layout);

  //  tabWidget->addTab(boxGuiyue,tr("测量参数"));
    tabWidget->addTab(widgetBc,tr("参数设置"));
    tabWidget->addTab(widgetInfo,tr("系统信息"));

    QVBoxLayout *topLayout = new QVBoxLayout;
    topLayout->addWidget(tabWidget);
    /*
    btnSysOk=new QPushButton(tr("确定"));
    btnSysCancel=new QPushButton(tr("取消"));
    btnSysOk->setFont(ft);
    btnSysOk->setMaximumWidth(60);
    btnSysOk->setMinimumHeight(60);
    btnSysCancel->setFont(ft);
    btnSysCancel->setMaximumWidth(60);
    btnSysCancel->setMinimumHeight(60);
    btnSysOk->setStyleSheet("background-image:url(:image/bj-1.jpg);color:rgb(250,155,50);");
    btnSysCancel->setStyleSheet("background-image:url(:image/bj-1.jpg);color:rgb(250,155,50);");

    QHBoxLayout *lowLayout = new QHBoxLayout;
    lowLayout->addWidget(btnSysOk);
    lowLayout->addWidget(btnSysCancel);
*/
  //  QHBoxLayout *maLayout = new QHBoxLayout;
 //   maLayout->addSpacing(10);
  //  maLayout->addLayout(topLayout);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(topLayout);
    mainLayout->addStretch(1);
  //  mainLayout->addLayout(lowLayout);
    setLayout(mainLayout);
}
void SysPage::inittab()
{
    tabMU=new QTableView();
    tabList=new QTableView();
    QFont ft;
    ft.setPointSize(14);
    ft.setBold(true);
    tabMU->setFont(ft);

  //  tabMU->setStyleSheet("background-color:rgb(0,0,0);color:rgb(250,255,250);");
  //  tabMU->setEditTriggers(QTableView::NoEditTriggers);//设置非编辑状态
  //  tabMU->setSelectionBehavior(QTableView::SelectRows);//设置点击行为行
    model1 = new QStandardItemModel();
    model1->setColumnCount(4);
    model1->setRowCount(1);
    model1->setHeaderData(0,Qt::Horizontal,tr("APPID"));
    model1->setHeaderData(1,Qt::Horizontal,tr("MAC"));
    model1->setHeaderData(2,Qt::Horizontal,tr("采样频率"));
    model1->setHeaderData(3,Qt::Horizontal,tr("ASDU数目"));

  //  tabWc->horizontalHeader()->hide();
    tabMU->verticalHeader()->hide();
    tabMU->setModel(model1);
    tabMU->resizeColumnsToContents();
    tabMU->setColumnWidth(0,121);
    tabMU->setColumnWidth(1,240);
    tabMU->setColumnWidth(2,120);
    tabMU->setColumnWidth(3,110);

    tabList->setFont(ft);
    tabList->setEditTriggers(QTableView::NoEditTriggers);//设置非编辑状态
    tabList->setSelectionBehavior(QTableView::SelectRows);//设置点击行为行
    model2 = new QStandardItemModel();
    model2->setColumnCount(4);
    model2->setRowCount(1);
    model2->setHeaderData(0,Qt::Horizontal,tr("APPID"));
    model2->setHeaderData(1,Qt::Horizontal,tr("通道数"));
    model2->setHeaderData(2,Qt::Horizontal,tr("描述"));
    model2->setHeaderData(3,Qt::Horizontal,tr("端口"));

  //  tabWc->horizontalHeader()->hide();
    tabList->verticalHeader()->hide();
    tabList->setModel(model2);
    tabList->resizeColumnsToContents();
    tabList->setColumnWidth(0,90);
    tabList->setColumnWidth(1,150);
    tabList->setColumnWidth(2,110);
    tabList->setColumnWidth(3,110);
    tabList->setVisible(false);
}

WcPage::WcPage(QWidget *parent)
    : QWidget(parent)
{
    QFont ft;
    ft.setPointSize(10);
    ft.setBold(true);
    QLabel *labXuhao=new QLabel(tr("序号"));
    QLabel *labTbfs=new QLabel(tr("同步方式"));
    QLabel *labBzxz=new QLabel(tr("标准选择"));
    QLabel *labBcxz=new QLabel(tr("被测选择"));
    QLabel *labDate=new QLabel(tr("测试时间"));
    labDate->setFont(ft);
    labDate->setMaximumWidth(96);
  //  labDate->setStyleSheet("color:rgb(255,255,255);");
    labYc=new QLabel(tr("额定一次电流"));
    labYcDw=new QLabel(tr("A"));
    labDataCount=new QLabel("");
 //   labXuhao->setStyleSheet("color:rgb(255,255,255);");
    labXuhao->setFont(ft);
    labXuhao->setMinimumWidth(96);
 //   labTbfs->setStyleSheet("color:rgb(255,255,255);");
    labTbfs->setFont(ft);
 //   labBzxz->setStyleSheet("color:rgb(255,255,255);");
    labBzxz->setFont(ft);
    labBzxz->setMinimumWidth(96);
  //  labBcxz->setStyleSheet("color:rgb(255,255,255);");
    labBcxz->setFont(ft);
 //   labYc->setStyleSheet("color:rgb(255,255,255);");
    labYc->setFont(ft);
 //   labYcDw->setStyleSheet("color:rgb(255,255,255);");
    labYcDw->setFont(ft);
 //   labDataCount->setStyleSheet("color:rgb(255,255,255);");
    labDataCount->setFont(ft);
    labDataCount->setMinimumWidth(200);

    txtXuhao=new QLineEdit("");
    txtTbfs=new QLineEdit("");
    txtBzxz=new QLineEdit("");
    txtBcxz=new QLineEdit("");
    txtYc=new QLineEdit("");
    txtDate=new QLineEdit("");
  //  txtXuhao->setStyleSheet("color:rgb(250,155,50);");
    txtXuhao->setFont(ft);
  //  txtTbfs->setStyleSheet("color:rgb(250,155,50);");
    txtTbfs->setFont(ft);
 //   txtBzxz->setStyleSheet("color:rgb(250,155,50);");
    txtBzxz->setFont(ft);
  //  txtBcxz->setStyleSheet("color:rgb(250,155,50);");
    txtBcxz->setFont(ft);
  //  txtYc->setStyleSheet("color:rgb(250,155,50);");
    txtYc->setFont(ft);
    txtYc->setMaximumWidth(100);
    txtDate->setFont(ft);
    txtDate->setMaximumWidth(120);
 //   txtDate->setStyleSheet("color:rgb(250,155,50);");
    inittabWc();
    btnFirst=new QPushButton("");
    btnFirst->setMinimumHeight(30);
    btnFirst->setMaximumWidth(30);
    btnFirst->setStyleSheet("background-image:url(:image/first.png);color:rgb(250,155,50);");
    btnPrevious=new QPushButton("");
    btnPrevious->setMinimumHeight(30);
    btnPrevious->setMaximumWidth(30);
    btnPrevious->setStyleSheet("background-image:url(:image/previous.png);color:rgb(250,155,50);");
    btnNext=new QPushButton("");
    btnNext->setMinimumHeight(30);
    btnNext->setMaximumWidth(30);
    btnNext->setStyleSheet("background-image:url(:image/next.png);color:rgb(250,155,50);");
    btnLast=new QPushButton("");
    btnLast->setMinimumHeight(30);
    btnLast->setMaximumWidth(30);
    btnLast->setStyleSheet("background-image:url(:image/last.png);color:rgb(250,155,50);");
    btnDel=new QPushButton("");
    btnDel->setMinimumHeight(30);
    btnDel->setMaximumWidth(30);
    btnDel->setStyleSheet("background-image:url(:image/del.png);color:rgb(250,155,50);");
    btnFind=new QPushButton("");
    btnFind->setMinimumHeight(30);
    btnFind->setMaximumWidth(30);
    btnFind->setStyleSheet("background-image:url(:image/find.png);color:rgb(250,155,50);");
    QHBoxLayout *topLayout = new QHBoxLayout;
    topLayout->addWidget(labXuhao);
    topLayout->addWidget(txtXuhao);
    topLayout->addWidget(labTbfs);
    topLayout->addWidget(txtTbfs);
    QHBoxLayout *bzLayout = new QHBoxLayout;
    bzLayout->addWidget(labBzxz);
    bzLayout->addWidget(txtBzxz);
    bzLayout->addWidget(labBcxz);
    bzLayout->addWidget(txtBcxz);
    QHBoxLayout *ycLayout = new QHBoxLayout;
    ycLayout->addWidget(labDate);
    ycLayout->addWidget(txtDate);
    ycLayout->addWidget(labYc);
    ycLayout->addWidget(txtYc);
    ycLayout->addWidget(labYcDw);
    ycLayout->addStretch(1);
    QHBoxLayout *btnLayout = new QHBoxLayout;
    btnLayout->addWidget(labDataCount);
    //btnLayout->addWidget(btnFind);
    btnLayout->addWidget(btnFirst);
    btnLayout->addWidget(btnPrevious);
    btnLayout->addWidget(btnNext);
    btnLayout->addWidget(btnLast);
    btnLayout->addWidget(btnDel);
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(topLayout);
    mainLayout->addLayout(bzLayout);
    mainLayout->addLayout(ycLayout);
    mainLayout->addWidget(tabWc);
    mainLayout->addLayout(btnLayout);
    setLayout(mainLayout);
}

void WcPage::inittabWc()
{
    tabWc=new QTableView();
    QFont ft;
    ft.setPointSize(10);
    ft.setBold(true);
    tabWc->setFont(ft);
  //  tabWc->setStyleSheet("color:rgb(250,0,255);");
    tabWc->setAlternatingRowColors(true);
 //   tabWc->setStyleSheet("background-color:rgb(0,100,255);color:rgb(255,0,0);");
    // 由内容调整列 resizeColumnsToContents();
    tabWc->setEditTriggers(QTableView::NoEditTriggers);//设置非编辑状态
    tabWc->setSelectionBehavior(QTableView::SelectRows);//设置点击行为行
  //   tabWc->setSelectionBehavior(QTableView::SelectColumns);//设置点击行为列
  //   tabWc->setShowGrid(false);   //不显示中间的线
//     tabWc->setMaximumWidth(315);
   //  tabTd->setMinimumWidth(280);
 //    tabWc->setMaximumHeight(32);
/*
    QFont font=this->font();
    font.setPointSize(10);
    QStandardItemModel *model = new QStandardItemModel();
    QStandardItem* item1=new QStandardItem();
    item1->setFont(font);
    item1->setTextAlignment(Qt::AlignCenter);
    QStandardItem* item2=new QStandardItem();
    item2->setFont(font);
    item2->setTextAlignment(Qt::AlignCenter);
    QStandardItem* item3=new QStandardItem();
    item3->setFont(font);
    item3->setTextAlignment(Qt::AlignCenter);
    QStandardItem* item4=new QStandardItem();
    item4->setFont(font);
    item4->setTextAlignment(Qt::AlignCenter);
    QStandardItem* item5=new QStandardItem();
    item5->setFont(font);
    item5->setTextAlignment(Qt::AlignCenter);
    QStandardItem* item6=new QStandardItem();
    item6->setFont(font);
    item6->setTextAlignment(Qt::AlignCenter);

    item1->setText(tr("标准百分点"));
    item2->setText(tr("被测百分点"));
    item3->setText(tr("标准有效值"));
    item4->setText(tr("被测有效值"));
    item5->setText(tr("比差"));
    item6->setText(tr("角差"));

    QList<QStandardItem*> item;
    item << item1<< item2<< item3<< item4<< item5<< item6;
    model->appendRow(item);
*/
    model = new QStandardItemModel();
    model->setColumnCount(6);
    model->setHeaderData(0,Qt::Horizontal,tr("检定点"));
    model->setHeaderData(1,Qt::Horizontal,tr("被测百分点"));
    model->setHeaderData(2,Qt::Horizontal,tr("标准有效值"));
    model->setHeaderData(3,Qt::Horizontal,tr("被测有效值"));
    model->setHeaderData(4,Qt::Horizontal,tr("比差"));
    model->setHeaderData(5,Qt::Horizontal,tr("角差"));

  //  tabWc->horizontalHeader()->hide();
    tabWc->verticalHeader()->hide();
    tabWc->setModel(model);
    tabWc->resizeColumnsToContents();

    tabWc->setColumnWidth(0,70);
    tabWc->setColumnWidth(1,90);
    tabWc->setColumnWidth(2,110);
    tabWc->setColumnWidth(3,110);
    tabWc->setColumnWidth(4,90);
    tabWc->setColumnWidth(5,90);
    tabWc->setColumnHidden(1,true);
}


BwjyPage::BwjyPage(QWidget *parent)
    : QWidget(parent)
{
    QFont ft;
    ft.setPointSize(10);
    ft.setBold(true);
    QString sty="border: 1px solid #636363;border-radius: 5px;padding:2px;background:none;selection-background-color:#4D4D4D;color:#FFFFFF;background-color:rgb(30,66,92)";
    tabWidget=new QTabWidget();
    tabWidget->setMinimumHeight(250);
    tabWidget->setFont(ft);
    ft.setPointSize(11);
    widgetWZX=new QWidget();
    labDzl=new QLabel(tr("丢帧数："));
    labDzl->setFont(ft);
    txtDzl=new QLineEdit();
    txtDzl->setFont(ft);
    QHBoxLayout *dzlLayout = new QHBoxLayout;
    dzlLayout->addWidget(labDzl);
 //   dzlLayout->addWidget(txtDzl);
    dzlLayout->addWidget(txtDzl);
    dzlLayout->addStretch(1);
  //  QVBoxLayout *oneLayout = new QVBoxLayout;
 //   oneLayout->addLayout(dzlLayout);
    widgetWZX->setLayout(dzlLayout);

    widgetMU=new QWidget();
    QLabel *labYs=new QLabel(tr("绝对延时时间(μs):"));
    QLabel *labMaxYs=new QLabel(tr("最大值(μs):"));
    QLabel *labMinYs=new QLabel(tr("最小值(μs):"));
    QLabel *labAvgYs=new QLabel(tr("平均值(μs):"));
    QLabel *labMaxJg=new QLabel(tr("报文间隔时间最大值(μs):"));
    QLabel *labMinJg=new QLabel(tr("报文间隔时间最小值(μs):"));

    QLabel *laberror1=new QLabel(tr("偏差小于 2 μs (%):"));
    QLabel *laberror2=new QLabel(tr("偏差为 2-4 μs (%):"));
    QLabel *laberror3=new QLabel(tr("偏差为 4-8 μs (%):"));
    QLabel *laberror4=new QLabel(tr("偏差大于 8 μs (%):"));

    txterror1 = new QLabel();
    txterror1->setStyleSheet(sty);
    txterror1->setMinimumWidth(100);
    txterror1->setFont(ft);

    txterror2 = new QLabel();
    txterror2->setStyleSheet(sty);
    txterror2->setMinimumWidth(100);
    txterror2->setFont(ft);

    txterror3 = new QLabel();
    txterror3->setStyleSheet(sty);
    txterror3->setMinimumWidth(100);
    txterror3->setFont(ft);

    txterror4 = new QLabel();
    txterror4->setStyleSheet(sty);
    txterror4->setMinimumWidth(100);
    txterror4->setFont(ft);

    labMaxYs->setMinimumWidth(80);
    labMinYs->setMinimumWidth(80);
    labAvgYs->setMinimumWidth(80);
    labMaxJg->setMinimumWidth(150);
    labMinJg->setMinimumWidth(150);

    QLabel *labbwall=new QLabel(tr("总报文数:"));
    QLabel *labbwlost=new QLabel(tr("丢失包数:"));
    QLabel *labbwerror=new QLabel(tr("错序包数:"));
    labbwall->setMinimumWidth(80);
    labbwlost->setMinimumWidth(80);
    labbwerror->setMinimumWidth(80);

    txtYs=new QLineEdit();
    txtMaxYs=new QLineEdit();
    txtMinYs=new QLineEdit();
    txtAvgYs=new QLineEdit();
    txtMaxJg=new QLineEdit();
    txtMinJg=new QLineEdit();

    txtBwAll=new QLineEdit();
    txtBwLost=new QLineEdit();
    txtBwError=new QLineEdit();

    txtMaxYs->setMinimumWidth(80);
    txtMinYs->setMinimumWidth(80);
    txtAvgYs->setMinimumWidth(80);
    txtBwAll->setMinimumWidth(80);
    txtBwLost->setMinimumWidth(80);
    txtBwError->setMinimumWidth(80);
    txtMaxJg->setMinimumWidth(180);
    txtMinJg->setMinimumWidth(185);

    cboTime=new QComboBox();
    setView(cboTime);
    cboInput=new QComboBox();
    setView(cboInput);
    cboTime->addItem("1");
    cboTime->addItem("2");
    cboTime->addItem("5");
    cboTime->addItem("10");
    cboTime->addItem("30");
    cboTime->addItem("1*60");
    cboTime->addItem("2*60");
    cboTime->addItem("5*60");
    cboTime->addItem("24*60");

    cboTime->setCurrentIndex(3);

    cboInput->addItem(tr("光口1"));
    cboInput->addItem(tr("光口2"));
    cboInput->addItem(tr("电口1"));
    cboInput->addItem(tr("电口2"));
    cboInput->setCurrentIndex(1);

    //using labInputmethod instead of cboInput
    ft.setBold(true);
    QLabel* labInputmethod = new QLabel(tr("光口3"));
    labInputmethod->setFont(ft);
    labInputmethod->setStyleSheet("color:#909000;text-align:center;");

    ft.setBold(false);

    QLabel *labTime=new QLabel(tr("测试时间"));
    QLabel *labTimeDw=new QLabel(tr("分钟"));
    QLabel *labInput=new QLabel(tr("输入端口"));
    labInfo=new QLabel();
    labInfo->setMinimumWidth(150);
    labInfo->setFont(ft);

    //cboTime->setStyleSheet(sty);
    cboInput->setStyleSheet(sty);
    labInput->setMinimumWidth(80);
    labTime->setMinimumWidth(80);
    cboTime->setMinimumWidth(120);
    cboInput->setMinimumWidth(200);

    QHBoxLayout *cs1Layout = new QHBoxLayout;
    cs1Layout->addWidget(labInput);
//    cs1Layout->addWidget(cboInput);
    cs1Layout->addWidget(labInputmethod);
    cs1Layout->addStretch(1);
    QHBoxLayout *cs2Layout = new QHBoxLayout;
    cs2Layout->addWidget(labTime);
    cs2Layout->addWidget(cboTime);
    cs2Layout->addWidget(labTimeDw);
    cs2Layout->addStretch(1);
    QVBoxLayout *csaLayout = new QVBoxLayout;
    csaLayout->addLayout(cs1Layout);
    csaLayout->addLayout(cs2Layout);
//    csaLayout->addStretch(1);
    csaLayout->addWidget(labInfo);

    ft.setPointSize(14);
    labYs->setFont(ft);
    txtYs->setFont(ft);
    ft.setPointSize(11);

    QHBoxLayout *ys1Layout = new QHBoxLayout;
    ys1Layout->addWidget(labYs);
    ys1Layout->addWidget(txtYs);
    ys1Layout->addStretch(1);

    QHBoxLayout *ys2Layout = new QHBoxLayout;
    ys2Layout->addWidget(labMaxYs);
    ys2Layout->addWidget(txtMaxYs);
    ys2Layout->addWidget(labMinYs);
    ys2Layout->addWidget(txtMinYs);
    ys2Layout->addWidget(labAvgYs);
    ys2Layout->addWidget(txtAvgYs);
    ys2Layout->addStretch(1);

    QVBoxLayout *ysLayout = new QVBoxLayout;
    ysLayout->addLayout(ys1Layout);
    ysLayout->addLayout(ys2Layout);
/*
    QVBoxLayout *jgLayout = new QVBoxLayout;
    jgLayout->addWidget(labMaxJg);
    jgLayout->addWidget(txtMaxJg);
    jgLayout->addWidget(labMinJg);
    jgLayout->addWidget(txtMinJg);
    jgLayout->addStretch(1);
  */
    QHBoxLayout *error1Layout = new QHBoxLayout;
    error1Layout->addWidget(laberror1);
    error1Layout->addWidget(txterror1);
    error1Layout->addStretch(1);

    QHBoxLayout *error2Layout = new QHBoxLayout;
    error2Layout->addWidget(laberror2);
    error2Layout->addWidget(txterror2);
    error2Layout->addStretch(1);

    QHBoxLayout *error3Layout = new QHBoxLayout;
    error3Layout->addWidget(laberror3);
    error3Layout->addWidget(txterror3);
    error3Layout->addStretch(1);

    QHBoxLayout *error4Layout = new QHBoxLayout;
    error4Layout->addWidget(laberror4);
    error4Layout->addWidget(txterror4);
    error4Layout->addStretch(1);

    QVBoxLayout *errorLayout = new QVBoxLayout;
    errorLayout->addLayout(error1Layout);
    errorLayout->addLayout(error2Layout);
    errorLayout->addLayout(error3Layout);
    errorLayout->addLayout(error4Layout);

    QHBoxLayout *jg1Layout = new QHBoxLayout;
    jg1Layout->addWidget(labMaxJg);
    jg1Layout->addWidget(txtMaxJg);

    jg1Layout->addStretch(1);
    QHBoxLayout *jg2Layout = new QHBoxLayout;
    jg2Layout->addWidget(labMinJg);
    jg2Layout->addWidget(txtMinJg);
    jg2Layout->addStretch(1);

    QVBoxLayout *jgLayout = new QVBoxLayout;
    jgLayout->addLayout(jg1Layout);
    jgLayout->addLayout(jg2Layout);

    /*
    QHBoxLayout *ddLayout = new QHBoxLayout;
    ddLayout->addWidget(labbwall);
    ddLayout->addWidget(txtBwAll);
    ddLayout->addWidget(labbwlost);
    ddLayout->addWidget(txtBwLost);
    ddLayout->addWidget(labbwerror);
    ddLayout->addWidget(txtBwError);
    ddLayout->addStretch(1);
    */
    QHBoxLayout *bw1Layout = new QHBoxLayout;
    bw1Layout->addWidget(labbwall);
    bw1Layout->addWidget(txtBwAll);
    bw1Layout->addStretch(1);
    QHBoxLayout *bw2Layout = new QHBoxLayout;
    bw2Layout->addWidget(labbwlost);
    bw2Layout->addWidget(txtBwLost);
    bw2Layout->addStretch(1);
    QHBoxLayout *bw3Layout = new QHBoxLayout;
    bw3Layout->addWidget(labbwerror);
    bw3Layout->addWidget(txtBwError);
    bw3Layout->addStretch(1);

    QVBoxLayout *ddLayout = new QVBoxLayout;
    ddLayout->addLayout( bw1Layout );
    ddLayout->addLayout( bw2Layout );
    ddLayout->addLayout( bw3Layout );

    QVBoxLayout *mu1Layout = new QVBoxLayout;
//    mu1Layout->addLayout(ysLayout);
   // mu1Layout->addLayout(csaLayout);
    mu1Layout->addLayout(ddLayout);
    mu1Layout->addStretch(1);
    mu1Layout->addLayout(errorLayout);

   // boxMU->setLayout(muLayout);

    QHBoxLayout *muLayout = new QHBoxLayout;
    muLayout->addLayout(csaLayout);
    muLayout->addLayout(mu1Layout);
    widgetMU->setLayout(muLayout);

//    widgetMU->setLayout(mu1Layout);

    widgetDS=new QWidget();

    combTestingTime = new QComboBox;
    setView(combTestingTime);
    combTestingTime->addItem(tr("10 秒"));

    txtDs=new QLabel("0.000");
    txtMaxDs=new QLabel("0.000");
    txtSs=new QLabel("0.000");
    txtMaxSs=new QLabel("0.000");
    txtDs->setStyleSheet(sty);
    txtMaxDs->setStyleSheet(sty);
    txtSs->setStyleSheet(sty);
    txtMaxSs->setStyleSheet(sty);

    txtDsTime=new QLineEdit("10");
    txtSsTime=new QLineEdit("600");
    cboBcsz=new QComboBox();
    setView(cboBcsz);
    cboBcsz->addItem(tr("电PPS"));
    cboBcsz->addItem(tr("光PPS"));

    cboBzsz=new QComboBox();
    setView(cboBzsz);
    cboBzsz->addItem(tr("接收光B码"));
    cboBzsz->addItem(tr("接收光秒脉冲"));
    cboBzsz->addItem(tr("同步输出"));

    // cboBzsz->setCurrentIndex(2);

    //using labInputmethod instead of cboInput
    QLabel* labDsInputmethod = new QLabel(tr("光口3"));
//    labDsInputmethod->setFont(ft);
    labDsInputmethod->setStyleSheet("color:#909000;text-align:center;");

    cboBzsz->setCurrentIndex(2);

    labInfoDs=new QLabel();
    labInfoDs->setMinimumWidth(200);
    labDs=new QLabel(tr("对时误差(μs)"));
    labMaxDs=new QLabel(tr("最大对时误差(μs)"));
    labSs=new QLabel(tr("守时误差(μs)"));
    labMaxSs=new QLabel(tr("最大守时误差(μs)"));
    QLabel *labDsTime=new QLabel(tr("对时测试时间(s)"));
    QLabel *labSsTime=new QLabel(tr("守时测试时间(s)"));
    QLabel *labBcsz=new QLabel(tr("被测时钟"));
    QLabel *labBzsz=new QLabel(tr("标准时钟"));

    QLabel *labDsInput = new QLabel(tr("报文输入"));

    labDs->setMinimumWidth(100);
    labMaxDs->setMinimumWidth(200);
    labSs->setMinimumWidth(100);
    labMaxSs->setMinimumWidth(200);
    labDsTime->setMinimumWidth(120);
    labSsTime->setMinimumWidth(120);
    labBcsz->setMinimumWidth(120);
    cboBcsz->setMinimumWidth(145);
    labBzsz->setMinimumWidth(120);

    cboBzsz->setMinimumWidth(145);
    cboBzsz->setMaximumWidth(145);
    combTestingTime->setMinimumWidth(145);
    combTestingTime->setMaximumWidth(145);

    txtDs->setMinimumWidth(120);
    txtMaxDs->setMinimumWidth(120);
    txtSs->setMinimumWidth(120);
    txtMaxSs->setMinimumWidth(120);

    //cboBcsz->setStyleSheet(sty);

    //cboBzsz->setStyleSheet(sty);
    //combTestingTime->setStyleSheet(sty);
    // labBzsz->setStyleSheet(sty);

    ft.setPointSize(11);
    beginDsTesting = new QRadioButton;
    beginDsTesting->setText(tr("对时误差"));
    beginDsTesting->setFont(ft);
    beginDsTesting->setStyleSheet("text-align:center;");
    //beginDsTesting->setStyleSheet(sty);
    beginDsTesting->setMinimumWidth(150);
    beginDsTesting->setChecked(true);

    beginSsTesting = new QRadioButton;
    beginSsTesting->setText(tr("守时误差"));
    beginSsTesting->setFont(ft);
    beginSsTesting->setMinimumWidth(150);
    beginSsTesting->setStyleSheet("text-align:center;");

//    beginDsTesting->setChecked(true);

    ft.setPointSize(11);

    QHBoxLayout *dsInputLayout = new QHBoxLayout;
    dsInputLayout->addWidget( labDsInput );
    dsInputLayout->addWidget( labDsInputmethod );

    QHBoxLayout *dsssLayout = new QHBoxLayout;
    dsssLayout->addWidget( beginDsTesting );
    dsssLayout->addWidget(beginSsTesting);

    QHBoxLayout *dscs1Layout = new QHBoxLayout;
    dscs1Layout->addWidget(labBzsz);
    dscs1Layout->addWidget(cboBzsz);

    QHBoxLayout *dscs2Layout = new QHBoxLayout;
    labDsTime->setText(tr("测试时间"));
    dscs2Layout->addWidget(labDsTime);
    //dscs2Layout->addWidget(txtDsTime);
    dscs2Layout->addWidget(combTestingTime);

    QVBoxLayout *dscsLayout = new QVBoxLayout;
//    dscsLayout->addWidget(beginDsTesting);
//    dscsLayout->addWidget(beginSsTesting);
    dscsLayout->addStretch(1);
    dscsLayout->addLayout( dsssLayout );
    dscsLayout->addStretch(1);
    dscsLayout->addLayout(dsInputLayout);
    dscsLayout->addLayout(dscs1Layout);
    dscsLayout->addLayout(dscs2Layout);
    dscsLayout->addStretch(1);

//    ft.setPointSize(14);
    QLabel *labJDYS = new QLabel("绝对延时(μs)");
//    labJDYS->setFont(ft);
    labJDYS->setMinimumWidth(100);

    labCurrentJDYS= new QLabel("0.000");
//    labCurrentJDYS->setFont(ft);
    labCurrentJDYS->setMinimumWidth(120);
//    labCurrentJDYS->setMaximumWidth(200);
    labCurrentJDYS->setStyleSheet(sty);

    // labJDYS_avg = new QLabel("绝对时延-平均值(μs)");
    labJDYS_avg = new QLabel("额定延时 (μs)");
//    labJDYS_avg->setFont(ft);
    labJDYS_avg->setMinimumWidth(200);
//    labJDYS_avg->setMaximumWidth(130);

    labCurrentJDYS_avg= new QLabel("0.000");
//    labCurrentJDYS_avg->setFont(ft);
    labCurrentJDYS_avg->setMinimumWidth(120);
//    labCurrentJDYS_avg->setMaximumWidth(200);
    labCurrentJDYS_avg->setStyleSheet(sty);

//    QHBoxLayout* jdysAvgLayout = new QHBoxLayout;
//    jdysAvgLayout->addWidget(labJDYS_avg);
//    jdysAvgLayout->addWidget(labCurrentJDYS_avg);
//    jdysAvgLayout->addStretch(1);

//    QHBoxLayout* jdysLayout= new QHBoxLayout; //juedui yanshi
//    jdysLayout->addWidget(labJDYS);
// //   jdysLayout->addStretch(1);
//    jdysLayout->addWidget(labCurrentJDYS);
//    jdysLayout->addStretch(1);

//    QHBoxLayout* jdys2Layout = new QHBoxLayout;
//    jdys2Layout->addLayout(jdysLayout);
////    jdys2Layout->addStretch(1);
//    jdys2Layout->addLayout(jdysAvgLayout);
////    jdys2Layout->addStretch(2);

    QHBoxLayout* jdys2Layout = new QHBoxLayout;
    jdys2Layout->addWidget(labJDYS);
    jdys2Layout->addWidget(labCurrentJDYS);
    jdys2Layout->addWidget(labJDYS_avg);
    jdys2Layout->addWidget(labCurrentJDYS_avg);
    jdys2Layout->addStretch(1);

    QHBoxLayout *ds3Layout = new QHBoxLayout;
    ds3Layout->addWidget(labDs);
    ds3Layout->addWidget(txtDs);
    ds3Layout->addWidget(labMaxDs);
    ds3Layout->addWidget(txtMaxDs);
    ds3Layout->addWidget(labSs);
    ds3Layout->addWidget(txtSs);
    ds3Layout->addWidget(labMaxSs);
    ds3Layout->addWidget(txtMaxSs);
    ds3Layout->addStretch(1);

    QVBoxLayout* testResult= new QVBoxLayout;
    testResult->addStretch(1);
    testResult->addLayout(jdys2Layout);
    // testResult->addStretch(1);
    testResult->addLayout(ds3Layout);
    testResult->addStretch(1);
    testResult->addWidget(labInfoDs);

  //  widgetAdd=new QWidget();
  //  twCC=new QTabWidget();
  //  twCC->setMinimumHeight(290);
  //  twCC->setMinimumWidth(300);
  //  twCC->setTabPosition(QTabWidget::West);
  //  ft.setPointSize(10);
  //  twCC->setFont(ft);
  //  ft.setPointSize(12);
  //  inittabAdd();
  //  twCC->addTab(tabControl,tr("控制"));
 //   twCC->addTab(tabChannel,tr("通道"));
 //   QHBoxLayout *addLayout = new QHBoxLayout;
 //   addLayout->addWidget(tabInfo);
  //  addLayout->addWidget(twCC);
 //   widgetAdd->setLayout(addLayout);

    QHBoxLayout *dsAllLayout = new QHBoxLayout;
    dsAllLayout->addLayout(dscsLayout);
//    dsAllLayout->addLayout(jdysLayout);
    dsAllLayout->addSpacing(50);
    dsAllLayout->addLayout(testResult);
    dsAllLayout->addStretch(1);

    widgetDS->setLayout(dsAllLayout);

//    widgetDS->setVisible(false);

    inittabTd();
    widgetXB=new QWidget();
    QLabel *labXbNum=new QLabel(tr("谐波次数:"));
    cboXieboNum=new QComboBox();
    setView(cboXieboNum);
    cboXieboNum->setFont(ft);
    for(int i=5;i<41;i++)
        cboXieboNum->addItem(QString::number(i));
    cboXieboNum->setCurrentIndex(0);
    QLabel *labXbHyl=new QLabel(tr("谐波含有率(%)"));
    labXbHyl->setFont(ft);
    txtXbHyl=new QLineEdit();
    txtXbHyl->setMaximumWidth(100);
    txtXbHyl->setFont(ft);
    QLabel *labTdh=new QLabel(tr("通道号:"));
    cboTdh=new QComboBox();
    setView(cboTdh);
    cboTdh->setFont(ft);
    for(int i=1;i<97;i++)
        cboTdh->addItem(QString::number(i));

    cboXieboNum->setMinimumWidth(80);
    cboTdh->setMinimumWidth(130);
    //cboXieboNum->setStyleSheet(sty);
    //cboTdh->setStyleSheet(sty);
    QHBoxLayout *xbLayout = new QHBoxLayout;
    xbLayout->addWidget(labXbNum);
    xbLayout->addWidget(cboXieboNum);
    QHBoxLayout *xb1Layout = new QHBoxLayout;
    xb1Layout->addWidget(labXbHyl);
    xb1Layout->addWidget(txtXbHyl);
    xb1Layout->addStretch(1);
    QHBoxLayout *tdLayout = new QHBoxLayout;
    tdLayout->addWidget(labTdh);
    tdLayout->addWidget(cboTdh);
    QHBoxLayout *csLayout = new QHBoxLayout;
    csLayout->addLayout(tdLayout);
    csLayout->addSpacing(10);
    csLayout->addLayout(xbLayout);
    csLayout->addStretch(1);
    QHBoxLayout *xxLayout = new QHBoxLayout;
    xxLayout->addWidget(tabTd);
    xxLayout->addStretch(1);
    QVBoxLayout *allLayout = new QVBoxLayout;
    allLayout->addLayout(csLayout);
  //  allLayout->addWidget(tabTd);
    allLayout->addLayout(xxLayout);
    allLayout->addLayout(xb1Layout);
    widgetXB->setLayout(allLayout);

    tabTd->setStyleSheet("font:15px;");

    tabWidget->addTab(widgetMU,tr("报文质量测试"));
   // tabWidget->addTab(widgetWZX,tr("完整性测试"));
    tabWidget->addTab(widgetDS,tr("绝对延时及守时测试"));
    tabWidget->addTab(widgetXB,tr("谐波分析"));
    tabWidget->setTabPosition(QTabWidget::South);
  //  tabWidget->addTab(widgetAdd,tr("加量输出"));
    QVBoxLayout *topLayout = new QVBoxLayout;
    topLayout->addWidget(tabWidget);
    /*
    btnBwStart=new QPushButton(tr("开始"));
    btnBwStop=new QPushButton(tr("停止"));
    btnBwStart->setFont(ft);
    btnBwStart->setMaximumWidth(60);
    btnBwStart->setMinimumHeight(60);
    btnBwStop->setFont(ft);
    btnBwStop->setMaximumWidth(60);
    btnBwStop->setMinimumHeight(60);
    btnBwStart->setStyleSheet("background-image:url(:image/bj-1.jpg);color:rgb(250,155,50);");
    btnBwStop->setStyleSheet("background-image:url(:image/bj-1.jpg);color:rgb(250,155,50);");


    QHBoxLayout *lowLayout = new QHBoxLayout;
    lowLayout->addWidget(btnBwStart);
    lowLayout->addWidget(btnBwStop);

    btnBwStop->setEnabled(false);
*/
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(topLayout);
    mainLayout->addStretch(1);
  //  mainLayout->addLayout(lowLayout);
    setLayout(mainLayout);

    dsTestingIsChecked();

    connect(beginDsTesting, SIGNAL(toggled(bool)), this, SLOT( dsTestingIsChecked()) );
    connect(beginSsTesting, SIGNAL(toggled(bool)), this, SLOT( dsTestingIsChecked()) );
}

void BwjyPage::dsTestingIsChecked()
{
    combTestingTime->clear();

    labDs->setVisible(false);
    txtDs->setVisible(false);
    labMaxDs->setVisible(false);
    txtMaxDs->setVisible(false);

    labSs->setVisible(false);
    txtSs->setVisible(false);
    labMaxSs->setVisible(false);
    txtMaxSs->setVisible(false);

    labCurrentJDYS_avg->setVisible(false);
    labJDYS_avg->setVisible(false);

    if(  beginDsTesting->isChecked() )
    {
//        beginDsTesting->setStyleSheet("border: 1px solid #636363;border-radius: 5px;padding:2px;color:#909000;text-align:center;");
//        beginSsTesting->setStyleSheet("color:#ffffff;text-align:center;");

        combTestingTime->addItem(tr("10 秒 "));
        combTestingTime->addItem(tr("30 秒 "));
        combTestingTime->addItem(tr("1  分钟 "));
        combTestingTime->addItem(tr("10 分钟 "));
        combTestingTime->addItem(tr("60 分钟 "));

        combTestingTime->setCurrentIndex(2);

        labDs->setVisible(true);
        txtDs->setVisible(true);
        labMaxDs->setVisible(true);
        txtMaxDs->setVisible(true);

        labCurrentJDYS_avg->setVisible(true);
        labJDYS_avg->setVisible(true);
    }
    else
    {
 //       beginSsTesting->setStyleSheet("border: 1px solid #636363;border-radius: 5px;padding:2px;color:#909000;text-align:center;");
 //       beginDsTesting->setStyleSheet("color:#ffffff;text-align:center;");

        combTestingTime->addItem(tr("5 分钟 "));
        combTestingTime->addItem(tr("10分钟 "));
        combTestingTime->addItem(tr("30分钟 "));
        combTestingTime->addItem(tr("60分钟 "));
        combTestingTime->addItem(tr("24小时 "));

        combTestingTime->setCurrentIndex(1);

        labSs->setVisible(true);
        txtSs->setVisible(true);
        labMaxSs->setVisible(true);
        txtMaxSs->setVisible(true);
    }
}

void BwjyPage::inittabTd()
{
    tabTd=new QTableView();
    QFont ft;
    ft.setPointSize(8);
    ft.setBold(false);
    tabTd->setFont(ft);
    tabTd->setFocusPolicy(Qt::NoFocus);
    // tabTd->setShowGrid(false);   //不显示中间的线
    tabTd->setMinimumWidth(390);
    tabTd->setMaximumHeight(80);

     modelTd = new QStandardItemModel();
     modelTd->setColumnCount(8);

     QStandardItem* item2=new QStandardItem();
     QFont font=this->font();
   //  font.setPointSize(10);
   //  item2->setFont(font);
     item2->setTextAlignment(Qt::AlignCenter);
     item2->setFont(font);
   //  item2->setText(tr(" "));

     QList<QStandardItem*> item;
     item <<item2;

     modelTd->appendRow(item);

 //    tabTd->horizontalHeader()->hide();
 //   int i=  cboXieboNum->currentText().toInt()-1;
     xiebonum(4);

}


void BwjyPage::xiebonum(int ics)
{
    int iCiShu=ics;
   // int iCiShu=4;

    modelTd->setColumnCount(iCiShu+2);
    QString s1=tr("直流");
    modelTd->setHeaderData(0,Qt::Horizontal,s1);
    s1=tr("基波");
    modelTd->setHeaderData(1,Qt::Horizontal,s1);
    for(int i=0;i<iCiShu;i++)
    {
        QString s=QString::number(2+i);
        s+=tr("次谐波");
        modelTd->setHeaderData(i+2,Qt::Horizontal,s);
    }


    tabTd->verticalHeader()->hide();
    tabTd->setModel(modelTd);
    for(int i=0;i<iCiShu+2;i++)
      tabTd->setColumnWidth(i,65);
}

AllPage::AllPage(QWidget *parent)
            : QWidget(parent)
{
    QFont ft;
    ft.setPointSize(9);
    QVBoxLayout *t1Layout = new QVBoxLayout;
    QVBoxLayout *t2Layout = new QVBoxLayout;
    QVBoxLayout *t3Layout = new QVBoxLayout;
    QVBoxLayout *t4Layout = new QVBoxLayout;
    QVBoxLayout *t5Layout = new QVBoxLayout;
    QVBoxLayout *t6Layout = new QVBoxLayout;
    QVBoxLayout *t7Layout = new QVBoxLayout;
    QVBoxLayout *t8Layout = new QVBoxLayout;
    QVBoxLayout *t9Layout = new QVBoxLayout;
    QVBoxLayout *t10Layout = new QVBoxLayout;
    QVBoxLayout *t11Layout = new QVBoxLayout;
    QVBoxLayout *t12Layout = new QVBoxLayout;
    btnNext=new QPushButton(tr(">"));
    btnPre=new QPushButton(tr("<"));
    btnNext->setMaximumWidth(30);
    btnNext->setMaximumHeight(18);
    btnPre->setMaximumWidth(30);
    btnPre->setMaximumHeight(18);
    for (int i=0;i<12;i++)
    {
        labTd[i]=new QLabel("通道:"+QString::number(i+1));
        labTd[i]->setStyleSheet("color:#FFFFFF");
        widget[i]=new QWidget();
        widget[i]->setStyleSheet("background-color:#000000");
        widget[i]->setMaximumWidth(200);
        widget[i]->setMinimumHeight(120);
        widget[i]->setMaximumHeight(120);
    //    QVBoxLayout *tLayout[i] = new QVBoxLayout;

    }

    t1Layout->addWidget(labTd[0]);
    t1Layout->addWidget(widget[0]);
    t2Layout->addWidget(labTd[1]);
    t2Layout->addWidget(widget[1]);
    t3Layout->addWidget(labTd[2]);
    t3Layout->addWidget(widget[2]);
    QHBoxLayout *h4Layout = new QHBoxLayout;
    h4Layout->addWidget(labTd[3]);
 //  h4Layout->addStretch(1);
    h4Layout->addWidget(btnPre);
    h4Layout->addWidget(btnNext);
    t4Layout->addLayout(h4Layout);
    t4Layout->addWidget(widget[3]);
    t5Layout->addWidget(labTd[4]);
    t5Layout->addWidget(widget[4]);
    t6Layout->addWidget(labTd[5]);
    t6Layout->addWidget(widget[5]);
    t7Layout->addWidget(labTd[6]);
    t7Layout->addWidget(widget[6]);
    t8Layout->addWidget(labTd[7]);
    t8Layout->addWidget(widget[7]);
    t9Layout->addWidget(labTd[8]);
    t9Layout->addWidget(widget[8]);
    t10Layout->addWidget(labTd[9]);
    t10Layout->addWidget(widget[9]);
    t11Layout->addWidget(labTd[10]);
    t11Layout->addWidget(widget[10]);
    t12Layout->addWidget(labTd[11]);
    t12Layout->addWidget(widget[11]);
    QHBoxLayout *m1Layout = new QHBoxLayout;
    m1Layout->addLayout(t1Layout);
    m1Layout->addLayout(t2Layout);
    m1Layout->addLayout(t3Layout);
    m1Layout->addLayout(t4Layout);
    QHBoxLayout *m2Layout = new QHBoxLayout;
    m2Layout->addLayout(t5Layout);
    m2Layout->addLayout(t6Layout);
    m2Layout->addLayout(t7Layout);
    m2Layout->addLayout(t8Layout);
    QHBoxLayout *m3Layout = new QHBoxLayout;
    m3Layout->addLayout(t9Layout);
    m3Layout->addLayout(t10Layout);
    m3Layout->addLayout(t11Layout);
    m3Layout->addLayout(t12Layout);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(m1Layout);
    mainLayout->addLayout(m2Layout);
    mainLayout->addLayout(m3Layout);
    setLayout(mainLayout);
}
void AllPage::setTDH(int tdh)
{
    int mxh=0;
    btnPre->setEnabled(true);
    btnNext->setEnabled(true);

    if (tdh<12)
    {
        mxh=0;
        btnPre->setEnabled(false);
    }
    else if (tdh<24)
        mxh=1;
    else if (tdh<36)
        mxh=2;
    else if (tdh<48)
        mxh=3;
    else if (tdh<60)
        mxh=4;
    else if (tdh<72)
        mxh=5;
    else if (tdh<84)
        mxh=6;
    else if (tdh<96)
    {
        mxh=7;
        btnNext->setEnabled(false);
    }
    for (int i=mxh*12;i<mxh*12+12;i++)
    {
        labTd[i%12]->setText("通道:"+QString::number(i+1));
    }
}

SclPage::SclPage(QWidget *parent)
            : QWidget(parent)
{
    QFont ft;
    ft.setPointSize(12);

    tabScl=new QTableView();
    tabScl->setFont(ft);
    tabScl->setEditTriggers(QTableView::NoEditTriggers);//设置非编辑状态
    tabScl->setSelectionBehavior(QTableView::SelectRows);//设置点击行为行
    tabScl->setShowGrid(false);   //不显示中间的线
    tabScl->verticalHeader()->hide();
    /*
    QStandardItemModel *model=new QStandardItemModel(0,5);
    model->setHeaderData(0,Qt::Horizontal,tr("序号"));
    model->setHeaderData(1,Qt::Horizontal,tr("APPID"));
    model->setHeaderData(2,Qt::Horizontal,tr("MAC"));
    model->setHeaderData(3,Qt::Horizontal,tr("采样频率"));
    model->setHeaderData(4,Qt::Horizontal,tr("ASDU数目"));
   // tabTd->horizontalHeader()->hide();
    tabScl->verticalHeader()->hide();
    tabScl->setModel(model);
    tabScl->setColumnWidth(0,50);
    tabScl->setColumnWidth(1,80);
    tabScl->setColumnWidth(2,190);
    tabScl->setColumnWidth(3,90);
    tabScl->setColumnWidth(4,70);
*/
    tabSclInfo=new QTableView();
    tabSclInfo->setFont(ft);
    tabSclInfo->setEditTriggers(QTableView::NoEditTriggers);//设置非编辑状态
    tabSclInfo->setSelectionBehavior(QTableView::SelectRows);//设置点击行为行
    tabSclInfo->setShowGrid(false);   //不显示中间的线
    tabSclInfo->verticalHeader()->hide();
    tabSclInfo->setVisible(false);
    tabSclInfo->setColumnWidth(0,50);
    tabSclInfo->setColumnWidth(1,100);
    tabSclInfo->setColumnWidth(2,80);
    tabSclInfo->setColumnWidth(3,150);
    tabSclInfo->setColumnWidth(4,150);

    labTdh=new QLabel(tr("通道号:"));
    cboTdh=new QComboBox();
    setView(cboTdh);
    cboTdh->setFont(ft);
    cboTdh->setMinimumWidth(250);
  //  QString sty="QComboBox{border-radius: 3px;padding: 1px 10px 1px 5px;border: 1px solid #636363;}";
   // sty +="QComboBox::drop-down{subcontrol-origin: padding; subcontrol-position: top right;width: 15px;border-left-width: 1px;border-left-style: solid;border-top-right-radius: 3px;border-bottom-right-radius: 3px;border-left-color: #636363;}";
  //  sty +="QComboBox::down-arrow{image: url(:/image/array_down.png);}";

   // cboTdh->setStyleSheet(sty);

    btnOK=new QPushButton(tr("确定"));
    btnOK->setFont(ft);
    btnOK->setMaximumWidth(100);
    btnOK->setMinimumWidth(100);
    labInfo=new QLabel("");

    QHBoxLayout *btnLayout = new QHBoxLayout;
    btnLayout->addWidget(labInfo);

    btnLayout->addWidget(labTdh);
    btnLayout->addWidget(cboTdh);
    btnLayout->addStretch(1);
    btnLayout->addWidget(btnOK);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(tabScl);
    mainLayout->addWidget(tabSclInfo);
    mainLayout->addStretch(1);
    mainLayout->addLayout(btnLayout);
    setLayout(mainLayout);
}
AddPage::AddPage(QWidget *parent)
            : QWidget(parent)
{
    QFont ft;
    ft.setPointSize(11);
    ft.setBold(true);

    QLabel *labUn = new QLabel(tr("额定电压 (V, <5V) : "));
    labUn->setFont(ft);
    txtUn = new QLineEdit("1");
    txtUn->setFont(ft);

    QWidget *widgetUn = new QWidget;
    QHBoxLayout *layoutUn = new QHBoxLayout;
    layoutUn->addWidget(labUn);
    layoutUn->addWidget(txtUn);
    layoutUn->addStretch(1);
    widgetUn->setLayout(layoutUn);
    widgetUn->setFont(ft);

    QWidget *widgetPercent = new QWidget;
    widgetPercent->setStyleSheet("border:1px solid gray;border-radius:8px;");

    QHBoxLayout *layoutPercent = new QHBoxLayout;

    ft.setPointSize(9);
    QLabel *labPercent = new QLabel(tr("   检定点 (%) : "));
    labPercent->setStyleSheet("border: 0px");
    labPercent->setFont(ft);
    txtPercent = new QLineEdit("100");
    txtPercent->setFont(ft);

    ft.setPointSize(8);
    QLabel *labQuictset = new QLabel("  快速设置->");
    labQuictset->setFont(ft);
    labQuictset->setStyleSheet("border: 0px; color:gold");

    QPushButton *btnPercent1 = new QPushButton(tr("1%"));
    btnPercent1->setMinimumWidth(60);
    btnPercent1->setFont(ft);
    btnPercent1->setStyleSheet("color:gold; border-radius:5px;");
    QPushButton *btnPercent5 = new QPushButton(tr("5%"));
    btnPercent5->setMinimumWidth(60);
    btnPercent5->setFont(ft);
    btnPercent5->setStyleSheet("color:gold; border-radius:5px;");
    QPushButton *btnPercent20 = new QPushButton(tr("20%"));
    btnPercent20->setMinimumWidth(60);
    btnPercent20->setFont(ft);
    btnPercent20->setStyleSheet("color:gold; border-radius:5px;");
    QPushButton *btnPercent80 = new QPushButton(tr("80%"));
    btnPercent80->setMinimumWidth(60);
    btnPercent80->setFont(ft);
    btnPercent80->setStyleSheet("color:gold; border-radius:5px;");
    QPushButton *btnPercent100 = new QPushButton(tr("100%"));
    btnPercent100->setMinimumWidth(60);
    btnPercent100->setFont(ft);
    btnPercent100->setStyleSheet("color:gold; border-radius:5px;");
    QPushButton *btnPercent120 = new QPushButton(tr("120%"));
    btnPercent120->setMinimumWidth(60);
    btnPercent120->setFont(ft);
    btnPercent120->setStyleSheet("color:gold; border-radius:5px;");

    layoutPercent->addWidget(labPercent);
    layoutPercent->addWidget(txtPercent);
    layoutPercent->addWidget(labQuictset);
    layoutPercent->addWidget(btnPercent1);
    layoutPercent->addWidget(btnPercent5);
    layoutPercent->addWidget(btnPercent20);
    layoutPercent->addWidget(btnPercent80);
    layoutPercent->addWidget(btnPercent100);
    layoutPercent->addWidget(btnPercent120);

    widgetPercent->setLayout(layoutPercent);

    ft.setPointSize(10);
    ckboxHarmonic = new QCheckBox(tr(" 含有谐波"));
    ckboxHarmonic->setStyleSheet("QCheckBox{color: gold; border: 0px;}QCheckBox::indicator{ width:30px; height:30px;}");
    ckboxHarmonic->setFont(ft);

    ft.setPointSize(8);
    tabHarmonic = new QTableView;
    QStandardItemModel *modHarmonic = new QStandardItemModel();
    tabHarmonic->setFont(ft);
    tabHarmonic->horizontalHeader()->setStyleSheet("background-color:#121d22;border: 0px;font:15px");

    modHarmonic->setHorizontalHeaderItem(0, new QStandardItem(QObject::tr("谐波次数")));
    //tabHarmonic->horizontalHeader()->setResizeMode(0, QHeaderView::Fixed);
    modHarmonic->setHorizontalHeaderItem(1, new QStandardItem(QObject::tr("3")));
    //tabHarmonic->horizontalHeader()->setResizeMode(1, QHeaderView::Fixed);
    modHarmonic->setHorizontalHeaderItem(2, new QStandardItem(QObject::tr("5")));
    //tabHarmonic->horizontalHeader()->setResizeMode(2, QHeaderView::Fixed);
    modHarmonic->setHorizontalHeaderItem(3, new QStandardItem(QObject::tr("7")));
    //tabHarmonic->horizontalHeader()->setResizeMode(3, QHeaderView::Fixed);
    modHarmonic->setHorizontalHeaderItem(4, new QStandardItem(QObject::tr("9")));
    //tabHarmonic->horizontalHeader()->setResizeMode(4, QHeaderView::Fixed);
    modHarmonic->setHorizontalHeaderItem(5, new QStandardItem(QObject::tr("11")));

    QStandardItem* item1a=new QStandardItem();
    item1a->setTextAlignment(Qt::AlignCenter);
    item1a->setText(tr("含有率 (%)"));
    item1a->setFont(ft);
    QStandardItem* item2a=new QStandardItem();
    item2a->setTextAlignment(Qt::AlignCenter);
    item2a->setText(tr("0"));
    item2a->setFont(ft);
    QStandardItem* item3a=new QStandardItem();
    item3a->setTextAlignment(Qt::AlignCenter);
    item3a->setText(tr("0"));
    item3a->setFont(ft);
    QStandardItem* item4a=new QStandardItem();
    item4a->setTextAlignment(Qt::AlignCenter);
    item4a->setText(tr("0"));
    item4a->setFont(ft);
    QStandardItem* item5a=new QStandardItem();
    item5a->setTextAlignment(Qt::AlignCenter);
    item5a->setText(tr("0"));
    item5a->setFont(ft);
    QStandardItem* item6a=new QStandardItem();
    item6a->setTextAlignment(Qt::AlignCenter);
    item6a->setText(tr("0"));
    item6a->setFont(ft);
    QList<QStandardItem*> itema;
    itema<<item1a<<item2a<<item3a<<item4a<<item5a<<item6a;

    modHarmonic->appendRow(itema);

    tabHarmonic->setModel(modHarmonic);
    tabHarmonic->setEditTriggers(QAbstractItemView::CurrentChanged);
    tabHarmonic->verticalHeader()->hide();

    QWidget *widgetHarmonic = new QWidget;
    QVBoxLayout *layoutHarmonic = new QVBoxLayout;
    layoutHarmonic->addWidget(ckboxHarmonic);
    layoutHarmonic->addWidget(tabHarmonic);
    widgetHarmonic->setLayout(layoutHarmonic);
    widgetHarmonic->setStyleSheet("border:1px solid gray;border-radius:8px;");
    widgetHarmonic->setMinimumHeight(112);

    QVBoxLayout *layoutAnalog = new QVBoxLayout;
    layoutAnalog->addWidget(widgetUn);
    layoutAnalog->addWidget(widgetPercent);
    layoutAnalog->addWidget(widgetHarmonic);
    pageAnalog = new QWidget;
    pageAnalog->setLayout(layoutAnalog);

    ft.setPointSize(14);
   // widgetAdd=new QWidget();
    twCC=new QTabWidget();
    labInfo=new QLabel("");
    rdoMn=new QRadioButton(tr("模拟加量"));
    rdoFt3=new QRadioButton(tr("FT3加量"));

    inittabAdd();
    // rdoMn->setStyleSheet("color:#FFFFFF;");
    // rdoFt3->setStyleSheet("color:#FFFFFF;");
    labInfo->setFont(ft);
    rdoMn->setFont(ft);
    rdoFt3->setFont(ft);
    rdoMn->setChecked(true);

    twCC->setMinimumHeight(130);
    //  twCC->setMaximumWidth(1100);
    //  twCC->setTabPosition(QTabWidget::West);
    ft.setPointSize(10);
    twCC->setFont(ft);
    ft.setPointSize(12);

    twCC->addTab(tabControl,tr("控制"));
    twCC->addTab(tabChannel,tr("通道"));

    QVBoxLayout *selectLayout = new QVBoxLayout;
    selectLayout->addWidget(rdoMn);
    selectLayout->addWidget(rdoFt3);
    selectLayout->addStretch(1);

    QHBoxLayout *a1Layout = new QHBoxLayout;
//    a1Layout->addWidget(tabMn);
    a1Layout->addWidget(pageAnalog);
    a1Layout->addWidget(tabInfo);

    QHBoxLayout *a2Layout = new QHBoxLayout;
    a2Layout->addSpacing(10);
    a2Layout->addLayout(selectLayout);
    a2Layout->addLayout(a1Layout);
    a2Layout->addStretch(1);

    QHBoxLayout *a3Layout = new QHBoxLayout;
    a3Layout->addSpacing(15);
    a3Layout->addWidget(twCC);
    QVBoxLayout *addLayout = new QVBoxLayout;
    addLayout->addLayout(a2Layout);
    addLayout->addStretch(1);
  //  addLayout->addWidget(twCC);
    addLayout->addLayout(a3Layout);

    QHBoxLayout *btnLayout = new QHBoxLayout;
    btnLayout->addWidget(labInfo);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addSpacing(10);
    mainLayout->addLayout(addLayout);
    mainLayout->addStretch(1);
    mainLayout->addLayout(btnLayout);
   // mainLayout->setSpacing(0);
    mainLayout->setMargin(0);
    setLayout(mainLayout);

//    tabMn->setVisible(true);
    tabInfo->setVisible(false);
    twCC->setVisible(false);
    tabMn->setColumnHidden(1,true);

    QButtonGroup *grpQuickPercent = new QButtonGroup;
    grpQuickPercent->addButton(btnPercent1,1);
    grpQuickPercent->addButton(btnPercent5,2);
    grpQuickPercent->addButton(btnPercent20,3);
    grpQuickPercent->addButton(btnPercent80,4);
    grpQuickPercent->addButton(btnPercent100,5);
    grpQuickPercent->addButton(btnPercent120,6);

    connect(rdoMn,SIGNAL(toggled(bool)),this,SLOT(showMnOrFt3()));
    connect(rdoFt3,SIGNAL(toggled(bool)),this,SLOT(showMnOrFt3()));

    connect(grpQuickPercent, SIGNAL(buttonClicked (int)),this,SLOT(quickPercent(int)));
}

bool AddPage::analogCmd()
{
    float changeToVoltage;
    float Un = txtUn->text().toFloat();
    float percent = txtPercent->text().toFloat();

    int temp;

    cmdToDA.clear();

    cmdToDA[0] = 0xaa;

    if(Un < 0)
    {
        changeToVoltage = 0;
    }
    else if(Un > 5)
    {
        changeToVoltage = 5;
    }
    else
    {
        changeToVoltage = Un;
    }
    if(percent < 0)
    {
        percent =  0;
    }
    else if(percent > 120)
    {
        percent = 120;
    }

    changeToVoltage = changeToVoltage * percent / 100;

    //temp = changeToVoltage * 10000; // rating is 6.5536v
    temp = changeToVoltage * 9200.0;

    cmdToDA[1] = temp / 256;
    cmdToDA[2] = temp % 256;

    if(ckboxHarmonic->isChecked())
    {
        // cmdToDA[3] = 0x01;

        QModelIndex index;
        index = tabHarmonic->model()->index(0,1,QModelIndex());
        if(index.data().toInt() < 20)
        {
            cmdToDA[3] = index.data().toInt() * 2.5;
        }
        else
        {
            cmdToDA[3] = 50;
        }

        index = tabHarmonic->model()->index(0,2,QModelIndex());
        if(index.data().toInt() < 20)
        {
            cmdToDA[4] = index.data().toInt() * 2.5;
        }
        else
        {
            cmdToDA[4] = 50;
        }

        index = tabHarmonic->model()->index(0,3,QModelIndex());
        if(index.data().toInt() < 20)
        {
            cmdToDA[5] = index.data().toInt() * 2.5;
        }
        else
        {
            cmdToDA[5] = 50;
        }
        index = tabHarmonic->model()->index(0,4,QModelIndex());
        if(index.data().toInt() < 20)
        {
            cmdToDA[6] = index.data().toInt() * 2.5;
        }
        else
        {
            cmdToDA[6] = 50;
        }
        index = tabHarmonic->model()->index(0,5,QModelIndex());
        if(index.data().toInt() < 20)
        {
            cmdToDA[7] = index.data().toInt() * 2.5;
        }
        else
        {
            cmdToDA[7] = 50;
        }
    }
    else
    {
        // cmdToDA[3] = 0x00;
        cmdToDA[3] = 0x00;
        cmdToDA[4] = 0x00;
        cmdToDA[5] = 0x00;
        cmdToDA[6] = 0x00;
        cmdToDA[7] = 0x00;
    }
    qDebug()<<"cmd is ready: "<<cmdToDA.toHex();

    return true;
}

void AddPage::quickPercent(int btnId)
{
    // qDebug()<<"do nothing!"<<btnId;
    switch(btnId)
    {
        case 1: txtPercent->setText("1");break;
        case 2: txtPercent->setText("5");break;
        case 3: txtPercent->setText("20");break;
        case 4: txtPercent->setText("80");break;
        case 5: txtPercent->setText("100");break;
        case 6: txtPercent->setText("120");break;
        default: txtPercent->setText("100");
    }
}

void AddPage::getsendUdpAdd(char * ch,int flag)
{
    etc_add=(ETC_Add*)ch;
    memcpy(etc_add->de_name,"sanwei",6);
    etc_add->sf=flag;
    etc_add->wl=0;
    QModelIndex index;
    if (flag=='a')          //模拟加量
    {
        index = tabMn->model()->index(0,0,QModelIndex());
        etc_add->etc_mn.xbNum=index.data().toInt();
    //    index = tabInfo->model()->index(0,1,QModelIndex());
    //    etc_add->etc_mn.xdy=index.data().toFloat();
        index = tabMn->model()->index(0,2,QModelIndex());
        etc_add->etc_mn.yxz=index.data().toFloat();
      //  memset(etc_add->etc_ft3,0,sizeof(etc_add->etc_ft3));

        etc_add->etc_ft3.lx=0;  //类型  0:ft3; 1:扩展ft3
        etc_add->etc_ft3.cypl=0;    //采样频率 0: 4K; 1: 12.8K
        etc_add->etc_ft3.btl=0;  //波特率 0:2.5; 1:5; 2:10
        etc_add->etc_ft3.LNName=0;
        etc_add->etc_ft3.LDName[0]=0;
        etc_add->etc_ft3.LDName[1]=0;
        etc_add->etc_ft3.DSName=0;
        etc_add->etc_ft3.EDdl=0;
        etc_add->etc_ft3.EDzxdl=0;
        etc_add->etc_ft3.EDdy=0;
        etc_add->etc_ft3.EDys=0;
        etc_add->etc_ft3.status1[0]=0;
        etc_add->etc_ft3.status1[1]=0;
        etc_add->etc_ft3.status2[0]=0;
        etc_add->etc_ft3.status2[1]=0;
        etc_add->etc_ft3.tdNum=0;
        for(int i=0;i<24;i++)
        {
            etc_add->etc_ft3.fz[i]=0;
            etc_add->etc_ft3.fzdw[i]=0;
            etc_add->etc_ft3.xj[i]=0;
        }
    }
    else                    //ft3加量
    {
    //    memset(etc_add->etc_mn,0,sizeof(etc_add->etc_mn));
        etc_add->etc_mn.xbNum=0;
      //  etc_add->etc_mn.xdy=0;
        etc_add->etc_mn.yxz=0;

        index = tabInfo->model()->index(0,0,QModelIndex());
        if (index.data().toString()=="IEC60044-7/8(FT3)")
            etc_add->etc_ft3.lx=0;
        else
            etc_add->etc_ft3.lx=1;
        index = tabInfo->model()->index(0,1,QModelIndex());
        if (index.data().toString()=="4K")
            etc_add->etc_ft3.cypl=0;
        else
            etc_add->etc_ft3.cypl=1;
        index = tabInfo->model()->index(0,2,QModelIndex());
        if (index.data().toString()=="2.5M")
            etc_add->etc_ft3.btl=0;
        else if (index.data().toString()=="5M")
            etc_add->etc_ft3.btl=1;
        else
            etc_add->etc_ft3.btl=2;
        index = tabControl->model()->index(0,0,QModelIndex());
        bool ok;
        QString temp;
        temp=index.data().toString();
        etc_add->etc_ft3.LNName=temp.toInt(&ok,16);
        index = tabControl->model()->index(0,1,QModelIndex());
        QString sa=index.data().toString();
        QString sa1="0";
        QString sa2="0";
        if (sa.length()>4)
            sa=sa.right(4);
        if (sa.length()==4)
        {
            sa1=sa.left(2);
            sa2=sa.right(2);
        }
        else if(sa.length()==3)
        {
            sa1=sa.left(1);
            sa2=sa.right(2);
        }
        else
        {
            sa2=sa;
        }
        etc_add->etc_ft3.LDName[1]=sa1.toInt(&ok,16);
        etc_add->etc_ft3.LDName[0]=sa2.toInt(&ok,16);
        index = tabControl->model()->index(0,2,QModelIndex());
        temp=index.data().toString();
        etc_add->etc_ft3.DSName=temp.toInt(&ok,16);
        index = tabControl->model()->index(0,3,QModelIndex());
        etc_add->etc_ft3.EDdl=index.data().toInt();
        index = tabControl->model()->index(0,4,QModelIndex());
        etc_add->etc_ft3.EDzxdl=index.data().toInt();
        index = tabControl->model()->index(0,5,QModelIndex());
        etc_add->etc_ft3.EDdy=index.data().toInt();
        index = tabControl->model()->index(0,6,QModelIndex());
        etc_add->etc_ft3.EDys=index.data().toInt();
        index = tabControl->model()->index(0,7,QModelIndex());
        QString st=index.data().toString();
        QString st1="0";
        QString st2="0";
        if (st.length()>4)
            st=st.right(4);
        if (st.length()==4)
        {
            st1=st.left(2);
            st2=st.right(2);
        }
        else if(st.length()==3)
        {
            st1=st.left(1);
            st2=st.right(2);
        }
        else
        {
            st2=st;
        }
        etc_add->etc_ft3.status1[1]=st1.toInt(&ok,16);
        etc_add->etc_ft3.status1[0]=st2.toInt(&ok,16);
        index = tabControl->model()->index(0,8,QModelIndex());
        st=index.data().toString();
        st1="0";
        st2="0";
        if (st.length()>4)
            st=st.right(4);
        if (st.length()==4)
        {
            st1=st.left(2);
            st2=st.right(2);
        }
        else if(st.length()==3)
        {
            st1=st.left(1);
            st2=st.right(2);
        }
        else
        {
            st2=st;
        }
        etc_add->etc_ft3.status2[1]=st1.toInt(&ok,16);
        etc_add->etc_ft3.status2[0]=st2.toInt(&ok,16);
        index = tabControl->model()->index(0,9,QModelIndex());
        int iTds=index.data().toInt();
        etc_add->etc_ft3.tdNum=iTds;

        for(int i=0;i<iTds;i++)
        {
            QModelIndex index1, index2;

            index1 = tabChannel->model()->index(0,i,QModelIndex());
            index2 = tabChannel->model()->index(2,i,QModelIndex());

            int ifz=index1.data().toInt();

            if (index2.data().toString() == "A")
            {
                etc_add->etc_ft3.fz[i]=ifz;
                etc_add->etc_ft3.fzdw[i]='0';
            }
            else
            {
                etc_add->etc_ft3.fz[i]=ifz;
                etc_add->etc_ft3.fzdw[i]='1';
            }
            index = tabChannel->model()->index(1,i,QModelIndex());
            etc_add->etc_ft3.xj[i]=index.data().toInt();
        }
    }

}
int AddPage::getStructAddLen()
{
    return sizeof(ETC_Add);
}
void AddPage::showMnOrFt3()
{
    if (rdoMn->isChecked())
    {
        pageAnalog->setVisible(true);
        tabInfo->setVisible(false);
        twCC->setVisible(false);
    }
    else if (rdoFt3->isChecked())
    {
        pageAnalog->setVisible(false);
        tabInfo->setVisible(true);
        twCC->setVisible(true);
    }
}

void AddPage::inittabAdd()
{
    QFont ft;
    ft.setPointSize(8);
    ft.setBold(false);
    tabMn=new QTableView();
    tabInfo=new QTableView();
    tabControl=new QTableView();
    tabChannel=new QTableView();


  //  tabInfo->setSelectionBehavior(QTableView::SelectRows);//设置点击行为行
 //   tabControl->setSelectionBehavior(QTableView::SelectRows);//设置点击行为行
 //   tabChannel->setSelectionBehavior(QTableView::SelectRows);//设置点击行为行
    tabInfo->setEditTriggers(QTableView::NoEditTriggers);//设置非编辑状态
//    tabControl->setEditTriggers(QTableView::NoEditTriggers);//设置非编辑状态
//    tabChannel->setEditTriggers(QTableView::NoEditTriggers);//设置非编辑状态
    tabControl->setEditTriggers(QAbstractItemView::CurrentChanged);
    tabChannel->setEditTriggers(QAbstractItemView::CurrentChanged);
    tabMn->setEditTriggers(QAbstractItemView::CurrentChanged);
    tabChannel->setFont(ft);
    tabInfo->setFont(ft);
    tabControl->setFont(ft);
    tabMn->setFont(ft);

    QStandardItemModel *model0 = new QStandardItemModel();
    model0->setColumnCount(3);
    model0->setHeaderData(0,Qt::Horizontal,tr("谐波次数"));
    model0->setHeaderData(1,Qt::Horizontal,tr("谐波小电压(V)"));
    model0->setHeaderData(2,Qt::Horizontal,tr("谐波有效值(V)"));

    QStandardItem* item1a=new QStandardItem();
    item1a->setTextAlignment(Qt::AlignCenter);
    item1a->setText(tr("1"));
    QStandardItem* item2a=new QStandardItem();
    item2a->setTextAlignment(Qt::AlignCenter);
    item2a->setText(tr("0.5"));
    QStandardItem* item3a=new QStandardItem();
    item3a->setTextAlignment(Qt::AlignCenter);
    item3a->setText(tr("1"));
    QList<QStandardItem*> itemz;
    itemz<<item1a<<item2a<<item3a;

    model0->appendRow(itemz);
    tabMn->setModel(model0);
    tabMn->verticalHeader()->hide();

    QStandardItemModel *model1 = new QStandardItemModel();
     model1->setColumnCount(3);
     model1->setHeaderData(0,Qt::Horizontal,tr("类型"));
     model1->setHeaderData(1,Qt::Horizontal,tr("采样频率"));
     model1->setHeaderData(2,Qt::Horizontal,tr("波特率"));

     QStandardItem* item1=new QStandardItem();
     item1->setTextAlignment(Qt::AlignCenter);
     item1->setText(tr("扩展 FT3"));
     QStandardItem* item2=new QStandardItem();
     item2->setTextAlignment(Qt::AlignCenter);
     item2->setText(tr("4K"));
     QStandardItem* item3=new QStandardItem();
     item3->setTextAlignment(Qt::AlignCenter);
     item3->setText(tr("5M"));
     QList<QStandardItem*> item;
     item <<item1<<item2<<item3;

     model1->appendRow(item);
     tabInfo->setModel(model1);
     tabInfo->verticalHeader()->hide();
   //  tabInfo->resizeColumnsToContents();

     QStandardItemModel *model2 = new QStandardItemModel();
     model2->setColumnCount(10);
     model2->setHeaderData(0,Qt::Horizontal,tr("LNNAME"));
     model2->setHeaderData(1,Qt::Horizontal,tr("LDNAME"));
     model2->setHeaderData(2,Qt::Horizontal,tr("DSNAME"));
     model2->setHeaderData(3,Qt::Horizontal,tr("相电流(A)"));
     model2->setHeaderData(4,Qt::Horizontal,tr("中性点电流(A)"));
     model2->setHeaderData(5,Qt::Horizontal,tr("相电压(kV)"));
     model2->setHeaderData(6,Qt::Horizontal,tr("额定延时(μs)"));
     model2->setHeaderData(7,Qt::Horizontal,tr("状态字1"));
     model2->setHeaderData(8,Qt::Horizontal,tr("状态字2"));
     model2->setHeaderData(9,Qt::Horizontal,tr("通道数"));

     QStandardItem* item11=new QStandardItem();
     item11->setTextAlignment(Qt::AlignCenter);
     item11->setText(tr("02"));
     QStandardItem* item12=new QStandardItem();
     item12->setTextAlignment(Qt::AlignCenter);
     item12->setText(tr("4001"));
     QStandardItem* item13=new QStandardItem();
     item13->setTextAlignment(Qt::AlignCenter);
     item13->setText(tr("01"));
     QStandardItem* item14=new QStandardItem();
     item14->setTextAlignment(Qt::AlignCenter);
     item14->setText(tr("1000"));
     QStandardItem* item15=new QStandardItem();
     item15->setTextAlignment(Qt::AlignCenter);
     item15->setText(tr("1000"));
     QStandardItem* item16=new QStandardItem();
     item16->setTextAlignment(Qt::AlignCenter);
     item16->setText(tr("110"));
     QStandardItem* item17=new QStandardItem();
     item17->setTextAlignment(Qt::AlignCenter);
     item17->setText(tr("750"));
     QStandardItem* item18=new QStandardItem();
     item18->setTextAlignment(Qt::AlignCenter);
     item18->setText(tr("0000"));
     QStandardItem* item19=new QStandardItem();
     item19->setTextAlignment(Qt::AlignCenter);
     item19->setText(tr("0000"));
     QStandardItem* item20=new QStandardItem();
     item20->setTextAlignment(Qt::AlignCenter);
     item20->setText(tr("22"));
     QList<QStandardItem*> itema;
     itema <<item11<<item12<<item13<<item14<<item15<<item16<<item17<<item18<<item19<<item20;

     model2->appendRow(itema);
     tabControl->setModel(model2);
     tabControl->verticalHeader()->hide();
     tabControl->setStyleSheet("font:15px;");
     tabChannel->setStyleSheet("font:15px");
   //  tabControl->setMinimumWidth(300);
   //  tabControl->setColumnWidth(0,160);
  //   tabControl->resizeColumnsToContents();

     // inittabTdinfo(0);//12通道
      inittabTdinfo(1);

      tabMn->setMinimumWidth(270);
      tabMn->setMaximumHeight(80);
      tabMn->setMinimumHeight(80);
      tabMn->setColumnWidth(0,110);
      tabMn->setColumnWidth(1,150);
      tabMn->setColumnWidth(2,160);
      tabInfo->setMinimumWidth(420);
      tabInfo->setMaximumHeight(80);
      tabInfo->setMinimumHeight(80);
      tabInfo->setColumnWidth(0,180);
      tabInfo->setColumnWidth(1,120);
      tabInfo->setColumnWidth(2,120);
}
void AddPage::inittabTdinfo(int flag)
{
    QFont ft;
    ft.setPointSize(8);
    ft.setBold(false);
    int inum=13;
    QStandardItemModel *model1 = new QStandardItemModel();
 //   if(flag==0)
 //       model1->setRowCount(12);
 //   else
 //       model1->setRowCount(22);
    model1->setRowCount(3);
  //  for(int i=1;i<13;i++)
  //      model1->setHeaderData(i-1,Qt::Vertical,QString::number(i));

    model1->setHeaderData(0,Qt::Vertical,tr("幅值"));
    model1->setHeaderData(1,Qt::Vertical,tr("相角(°)"));
    model1->setHeaderData(2,Qt::Vertical,tr("单位"));

    if (flag==0)//12通道
    {
        inum=13;
    }
    else
    {
        inum=23;
    }
    QModelIndex index=tabControl->model()->index(0,3,QModelIndex());
    QString s=index.data().toString();
    for(int i=0;i<7;i++)
    {
        QStandardItem* item1=new QStandardItem();
        item1->setTextAlignment(Qt::AlignCenter);
        item1->setText(s);
        QStandardItem* item2=new QStandardItem();
        item2->setTextAlignment(Qt::AlignCenter);
        item2->setText(tr("0"));
        QList<QStandardItem*> item;
        QStandardItem* item3=new QStandardItem();
        item3->setTextAlignment(Qt::AlignCenter);
        item3->setText(tr("A"));
        item <<item1<<item2<<item3;
        model1->appendColumn(item);
    }
    index=tabControl->model()->index(0,5,QModelIndex());
    s=index.data().toString();
    for(int i=8;i<inum;i++)
    {
        QStandardItem* item1=new QStandardItem();
        item1->setTextAlignment(Qt::AlignCenter);
        item1->setText(s);
        QStandardItem* item2=new QStandardItem();
        item2->setTextAlignment(Qt::AlignCenter);
        item2->setText(tr("0"));
        QStandardItem* item3=new QStandardItem();
        item3->setTextAlignment(Qt::AlignCenter);
        item3->setText(tr("kV"));

        QList<QStandardItem*> item;
        item <<item1<<item2<<item3;
        model1->appendColumn(item);
     }

    tabChannel->setModel(model1);
    tabChannel->setMaximumHeight(200);
    for(int i=0;i<inum;i++)
        tabChannel->setColumnWidth(i,80);
 //   tabChannel->horizontalHeader()->hide();
 //   tabChannel->setMinimumWidth(300);
 //   for(int i=0;i<inum;i++)
 //       tabChannel->setRowHeight(i,25);
 //   tabChannel->setColumnWidth(0,140);
 //   tabChannel->setColumnWidth(1,120);

    tabChannel->setStyleSheet("QScrollBar{"
                              "background:#bbb; Height: 30px;"
                              "}");
}
ExPage::ExPage(QWidget *parent)
    : QWidget(parent)
{
}
MuPage::MuPage(QWidget *parent)
    : QWidget(parent)
{
}
